Could not find class XXX referenced from method XXX.<YYY>

b-ryce picture b-ryce · Feb 8, 2013 · Viewed 49.6k times · Source

I'm working on a libGDX project and I have a class called CheerVArachnids that has another inline class which is an event listener. When I run this project on the desktop it works fine. BUT when I run on my Android device, it can't find that inline class and I get the following error:

Could not find class 'com.bbj.cva.CheerVArachnids$PlaceUnitListener', referenced from method com.bbj.cva.CheerVArachnids.<init>

Here are the important parts of my class:

package com.bbj.cva;

public class CheerVArachnids implements ApplicationListener {

    class PlaceUnitListener implements EventSubscriber<PlaceUnitEvent> {

        @Override
        public void onEvent(PlaceUnitEvent event) 
        {   
            //
        }
    }

    public CheerVArachnids() {

        EventBus.subscribe(PlaceUnitEvent.class, new PlaceUnitListener());
        EventBus.subscribe(RemoveScreenObjectEvent.class,
                new RemoveScreenObjectListener());
    }
}

Any ideas why on Android, at runtime it can't find that inline class?

Answer

CodeNoob picture CodeNoob · Feb 8, 2013

Since some ADT-Version you have to set which libraries / projects should be exported too.

Project-Propiertes -> Java Build Path -> Order and Export -> Check your Sources and other Libraries you are using.

Do these Export-Settings for your Core- and Android-Project.

Then it should work fine on Android.