1

I had deleted an activity named ProductList_Activity.java file. Now when I run the app it crashes with the following error. How to fix it?

error log:

E/AndroidRuntime(23686): FATAL EXCEPTION: main
E/AndroidRuntime(23686): Process: com.esouqatar.customer, PID: 23686
E/AndroidRuntime(23686): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.esouqatar.customer/com.esouqatar.customer.ProductList_Activity}: java.lang.ClassNotFoundException: Didn't find class "com.esouqatar.customer.ProductList_Activity" on path: DexPathList[[zip file "/data/app/com.esouqatar.customer-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
E/AndroidRuntime(23686):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2256)
E/AndroidRuntime(23686):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2405)
E/AndroidRuntime(23686):    at android.app.ActivityThread.access$800(ActivityThread.java:149)
E/AndroidRuntime(23686):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324)
E/AndroidRuntime(23686):    at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(23686):    at android.os.Looper.loop(Looper.java:211)
E/AndroidRuntime(23686):    at android.app.ActivityThread.main(ActivityThread.java:5315)
E/AndroidRuntime(23686):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(23686):    at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(23686):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941)             
E/AndroidRuntime(23686):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:736)   
E/AndroidRuntime(23686): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.esouqatar.customer.ProductList_Activity" on path: DexPathList[[zip file "/data/app/com.esouqatar.customer-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
E/AndroidRuntime(23686):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/AndroidRuntime(23686):    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime(23686):    at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
E/AndroidRuntime(23686):    at android.app.Instrumentation.newActivity(Instrumentation.java:1065)
E/AndroidRuntime(23686):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246)
E/AndroidRuntime(23686):    ... 10 more
E/AndroidRuntime(23686):    Suppressed: java.lang.ClassNotFoundException: com.esouqatar.customer.ProductList_Activity
E/AndroidRuntime(23686):        at java.lang.Class.classForName(Native Method)
E/AndroidRuntime(23686):        at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
E/AndroidRuntime(23686):        at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
E/AndroidRuntime(23686):        at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
E/AndroidRuntime(23686):        ... 13 more
E/AndroidRuntime(23686):    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
Scott
  • 1,863
  • 2
  • 24
  • 43
Tiny
  • 109
  • 12

3 Answers3

2

NoClassDefFoundError: is thrown when the definition of class in not available during runtime. This error also indicates that the definition of the class was found during the compilation of the application, but it is not available in the application’s classpath during runtime.More info to visit SO Answer.

How To Solve

In general, Clean & Rebuild Project Then Restart . Otherwise,

Verify that all required Java classes are included in the application’s classpath. The most common mistake is not to include all the necessary classes, before starting to execute a Java application that has dependencies on some external libraries.Courtesy

Community
  • 1
  • 1
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
0

Some Where in your code the class is still in use. Either find and remove class instatiation or restore the file if you need the file.

-1

Right click on your project and then Run As -> Java Application

This solved the issue for me.

Mahm00d
  • 3,881
  • 8
  • 44
  • 83