Reputation: 519
I know this may sound stupid but I am getting this issue for many days. As far I have observed, I am not repeating any Question. In some of my classes, when I try to add new method or copy code from an other class, I get NoClassDefFoundError. More interesting is that I change code in 3rd or 4th Activity but I am getting this error on Splash Activity. I am not adding any new library. Just simple adding a new method or copying code from other classes, I get this app crash. For now it is happening to a few classes. As I am not adding any new library, does it has something to do with my PC or Android Studio? Or I have something wrong with my project? Here is my dependencies list:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.squareup.picasso:picasso:2.5.0'
compile 'com.google.android.gms:play-services:7.3.0'
compile files('libs/isoparser-1.0.6.jar')
compile files('libs/aspectjrt-1.7.3.jar')
compile 'com.facebook.android:facebook-android-sdk:4.1.2'
compile 'org.twitter4j:twitter4j-core:4.0.3'
compile 'com.amazonaws:aws-android-sdk-s3:2.2.1'
compile 'com.amazonaws:aws-android-sdk-core:2.2.1'
}
And here is the error:
06-25 13:20:36.247 21879-21879/com.ali.myapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.ali.myapp.SplashActivity$1$1
at com.ali.myapp.SplashActivity$1.run(SplashActivity.java:47)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
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:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Upvotes: 0
Views: 86
Reputation:
If following steps mentioned in the answer by @CodeProcessor doesn't solve your issue, check and confirm that you are not duplicating any library in "libs" folder and gradle file.
For example if you have a .jar file in libs folder with name "isoparser-1.0.6.jar" and you are using compile 'isoparser-1.0.6.jar'
instead of compile files('libs/isoparser-1.0.6.jar')
, this will also cause NoClassDefFoundError
.
Upvotes: 1
Reputation: 1971
Something went wrong in incremental build system. One of this should help: 1.Menu Build -> Rebuild project 2.Delete folder /build 3.Close Android Studio, delete /build folder 4.Right click on your project -> "Open module settings" -> Dependencies tab -> check if Export is checked for your library
Upvotes: 0