1

I have designed 2 to 3 application in android studio 2.3.1 and gradle 3.2. and all are working fine when i run application from it to any device or emulator. but when i get that apk from build folder and install manually to device or emulator. its crashes everytime and give me error classnotfound. which is MainActivity.

I am using Mac.I tried many ways. even i build new project but still same error. below is logcat of it.

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.call.unblock/com.call.unblock.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.call.unblock.MainActivity" on path: DexPathList[[zip file "/data/app/com.call.unblock-2/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2236)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
                                                     at android.app.ActivityThread.access$800(ActivityThread.java:151)
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                     at android.os.Looper.loop(Looper.java:135)
                                                     at android.app.ActivityThread.main(ActivityThread.java:5254)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at java.lang.reflect.Method.invoke(Method.java:372)
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
                                                  Caused by: java.lang.ClassNotFoundException: Didn't find class "com.call.unblock.MainActivity" on path: DexPathList[[zip file "/data/app/com.call.unblock-2/base.apk"],nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]
                                                     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                     at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
                                                     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
                                                     at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                     at android.os.Looper.loop(Looper.java:135) 
                                                     at android.app.ActivityThread.main(ActivityThread.java:5254) 
                                                     at java.lang.reflect.Method.invoke(Native Method) 
                                                     at java.lang.reflect.Method.invoke(Method.java:372) 
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
                                                    Suppressed: java.lang.ClassNotFoundException: com.call.unblock.MainActivity
                                                     at java.lang.Class.classForName(Native Method)
                                                     at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                                     at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                                     at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                            ... 13 more
                                                  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

Help me with it. i can't go further with my application without solving this issue.

Sagar Maiyad
  • 12,655
  • 9
  • 63
  • 99
  • Is it possible you copied an invalid artifact? [Seems like this should work](http://stackoverflow.com/a/16709979/1790644). Try cleaning / rebuilding the project? Or [does this help](http://stackoverflow.com/a/20924305/1790644)? – Matt Clark May 19 '17 at 17:00

2 Answers2

1

is this a release build type / are you using proguard? if this is the case try using the 'keep' option in proguard-project.txt file... if this is a debug build type - try performing a decompiling of your apk (using 'apktool' for ex.) & check if the specified class is in your 'classes.jar' file

Sahar Weissman
  • 162
  • 1
  • 4
0

if code clean and re-build project is not working then that issue is in Android Studio bundle, you can import same Source code in another system it will work without any issue. i face the same issue previously two three times but by setting code on another system same code without changes works perfectly

Puneet Kumar
  • 306
  • 1
  • 3