Home » Android » android – ClassNotFoundException after upgrading to ADT 18

android – ClassNotFoundException after upgrading to ADT 18

Posted by: admin May 14, 2020 Leave a comment

Questions:

Since I updated ADT to 19, I started to get following error.
The problem happens whenever I start my apps.
I checked all the previous post related to this, but it seems none of them helps. any idea would be GREATLY appreciated…

My setup

  1. I currently have ADT 18, SDK 19, elcipse in Windows 7 64bit.
  2. I use library project which makes ashare.jar and all my external jars (i.e. dropbox, commons codec) are in “libs” folder in Library project (Ashare).
  3. I don’t use proguard.

How we see this problem.

  1. Create apk in eclipse > {MyProject} > Right click > Android Tools > Export signed application package
  2. install the apk in emulator or dev.phone using “adb install XXX.apk”
  3. Start the app. Then, BOOM. it throw the error.

Some noticeable things are

  1. It started to happen after I updated to ADT in my eclipse to version 18
  2. It happens only when I make signed apk and run it in emulator or dev.phone.
  3. I don’t see problem if I run my app using {MyProject} > Right click > Run As > Android Application
  4. When I checked inside of classes.dex, I see some classes are missing there. I am not sure, but I feel Build process is not including all classes in classes.dex
  5. During the export, there’s no error in eclipse console (I use verbose option in Android>Build>Build output setting)

Java Exception

05-07 08:52:48.336: D/AndroidRuntime(3055): Shutting down VM
05-07 08:52:48.336: W/dalvikvm(3055): threadid=1: thread exiting with uncaught exception (group=0x40a3e1f8)
05-07 08:52:48.340: E/AndroidRuntime(3055): FATAL EXCEPTION: main
05-07 08:52:48.340: E/AndroidRuntime(3055): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.acj0.barcodeexpdemo/com.acj0.barcodeexpdemo.Launcher}: java.lang.ClassNotFoundException: com.acj0.barcodeexpdemo.Launcher
05-07 08:52:48.340: E/AndroidRuntime(3055):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at android.os.Looper.loop(Looper.java:137)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at android.app.ActivityThread.main(ActivityThread.java:4424)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at java.lang.reflect.Method.invokeNative(Native Method)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at java.lang.reflect.Method.invoke(Method.java:511)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at dalvik.system.NativeStart.main(Native Method)
05-07 08:52:48.340: E/AndroidRuntime(3055): Caused by: java.lang.ClassNotFoundException: com.acj0.barcodeexpdemo.Launcher
05-07 08:52:48.340: E/AndroidRuntime(3055):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
05-07 08:52:48.340: E/AndroidRuntime(3055):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
05-07 08:52:48.340: E/AndroidRuntime(3055):     ... 11 more

UPDATE 5/7/2012

  • All my jars are in “libs” folder of Library project and I see all of them included in “Android Dependencies”

UPDATE 5/18/2012 – TEMPORARILY SOLVED

  • I found temporary solution. Right before running “Export signed application package”, I did “Clean” WITHOUT “build automatically” option checked. Then, I don’t see the error anymore. I don’t know why it works. If you have any idea, please let me know.
How to&Answers:

Put your externals jars in libs directory.
You can take a look at this link

Answer:

I had the same problem, although I did everything as described in the link lujop mentioned. Here is what is missing:

  1. Right click on your project > Build Path > Configure Build Path …
  2. Click the tab “Order and Export”
  3. Tick the checkboxes next to the libraries (Android x.x.x, Android Dependencies) and other Projects you are referring to
  4. Clean your project
  5. That should be it

I hope that helps!

Answer:

I had this too. Here’s my fix.
As per here:
http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17

Make there there are no “Referenced Libraries”. If there are any right-click them all and remove from build path. The folder should now be gone and you should only be left with “Android Dependencies”

Answer:

This drove me nuts as well for like a whole day , only to realize silly me application name in manifest was wrong .
For application name I had :
android:name=”com.diack.locdatafeeds”

it was missing my main activity
android:name=”com.diack.locdatafeeds.Mainactivity”

Hope it helps someone