Question

I am getting the following error when launching my glass app:

FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.example.glass.speeddisplay.SpeedDisplayMenuActivity
at com.example.glass.speeddisplay.service.SpeedService.onStartCommand(SpeedService.java:135)
at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:2359)
at android.app.ActivityThread.access$1900(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)

Line 135 of SpeedService.java:

Intent menuIntent = new Intent(this, SpeedDisplayMenuActivity.class);

This class is part of my source folder, which is checked to be exported in the project Build settings.

If I unzip the .apk in my bin folder, and dexdump the classes.dex file I do see that class:

Wesleys-MacBook-Pro:$ ~/apps/adt/sdk/build-tools/18.1.1/dexdump classes.dex | grep "Class desc" | grep SpeedDisplayMenu
    Class descriptor  : 'Lcom/example/glass/speeddisplay/SpeedDisplayMenuActivity$1;'
    Class descriptor  : 'Lcom/example/glass/speeddisplay/SpeedDisplayMenuActivity;'

Why would I be getting this exception on app launch?

Was it helpful?

Solution

NoClassDefFoundError is a little bit differente from ClassNotFoundExecption: it means that the main class cited class cannot intialize static block, cannot find other classes, ...

The proble is in SpeedDisplayMenuActivity

"Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found. The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found."

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top