1

I've received some bug reports with error "java.lang.NoClassDefFoundError: my.app.MyCustomClass". Those bug are report from device with android version "2.3.6".

The error always happen when I access a static variable from my.app.MyCustomClass, like MyCustomClass.SOME_VARIABLE.

Here is the stack trace.

java.lang.NoClassDefFoundError: my.app.MyCustomClass
at my.app.MyActivity$1.void run()(MyActivity.java55)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3770)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)
at dalvik.system.NativeStart.main(Native Method)

Part of gradle

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    minSdkVersion 10
    targetSdkVersion 21
    ...
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:support-v4:22.2.1'
    ...
}

What would be the possible cause of this issue?

Season
  • 1,178
  • 2
  • 22
  • 42
  • hmmm, is that all of the stacktrace? the class (`my.app.MyCustomClass`) is exists in your classpath right? – kucing_terbang Oct 02 '15 at 04:19
  • @Season : Please add your gradle file here..!! – AndiGeeky Oct 02 '15 at 04:20
  • @kucing_terbang that is the whole stacktrace. and I sure the class exists – Season Oct 03 '15 at 05:24
  • @Season then is it possible for you to post the code here and also make sure that the class has been configured in the class path? My guess the error is caused by either the class is missing in your classpath or something wrong with in the initialiser of the static variable you're using. – kucing_terbang Oct 03 '15 at 07:03

1 Answers1

0

Basically java.lang.NoClassDefFoundError means, that the class which you are trying to run was not found in the classpath. See answers to a similar question here

Community
  • 1
  • 1
bibi_bryan
  • 371
  • 3
  • 17