How to fix Class Not Found on Android - Could not find class XXX referenced from method XXX.

How to fix Class not found on Android from method XXX. on ADT

It’s common to start a new Android project and face some issues with some Java classes missing on ADT.

Especially when you are using inline class.

Also, your project may run without any issues on your desktop, but when you are testing on an Android device, you get an error like this:

For example:

Could not find class 'com.xxxnx.adt.Find$PlaceUnitListener', referenced from method com.xxxnx.adt.Find.<init>

The example below is an example of a Class that could generate the error:



package com.xxxnx.adt;

public class Find implements ApplicationListener {

    class PlaceUnitListener implements EventSubscriber {

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

    public Find() {

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

Resolve the problem “Could not find class XXX referenced from method XXX.<YYY>

To make your application find the class at runtime on Android, you need to configure your ADT to export the classes required for your application.

Follow those steps on your ADT.

Project → Properties → Java Build Path → Order and Export → Select your libraries.

It’s done! Clean your project and test it!

Leave a Comment

Your email address will not be published. Required fields are marked *

Free PDF with a useful Mind Map that illustrates everything you should know about AWS VPC in a single view.