Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

libgdx

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?

like image 989
b-ryce Avatar asked Feb 08 '13 04:02

b-ryce


2 Answers

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.

like image 170
CodeNoob Avatar answered Oct 30 '22 06:10

CodeNoob


In my case, everything worked fine until I installed the new updates for the SDK and Eclipse.

I got an error: "Could not find class..."

I found solution in another stackoverflow site.

I have a similar problem when using external jar (in my case openCSV). The reason I had a problem was due to a change in ADT 17 (or above). What I needed to do to resolve the problem was In Eclipse go to Properties -> Java build path -> Order and export. Mark my jar. Move jar to top of the list. The solution was found in the following page which reference to a very good article.

like image 12
syp_dino Avatar answered Oct 30 '22 08:10

syp_dino