11

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.
ChrsitopherJ
  • 131
  • 1
  • 5
  • Post the source of the classes you found missing from your dex file. Also try to capture the logcat generated during the odex process as the apk is installed. – Chris Stratton May 07 '12 at 17:00
  • I had a similar problem...Are the libraries included in a folder called lib? Or libs? You should go with the second one... – Shine May 07 '12 at 17:05
  • I had the same exception thrown when i updated SDK versions. The question and answer is ([here](http://stackoverflow.com/questions/9831019/updated-sdk-version-getting-classnotfoundexception-android-support-v4-view-vie)) – wdziemia May 07 '12 at 17:56
  • 5
    +1 for your second update. Disabling "Build automatically" fixed the problem for me. Everything else seems correct in my setup. – pjay_ Jul 20 '12 at 12:41
  • Also +1 for the second update. I have exatly the same problem after upgrading. Any new hints for the reason? Whats going wrong in ADT 18? Latest update is installed. – venni Dec 26 '12 at 23:27

4 Answers4

2

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

lujop
  • 13,504
  • 9
  • 62
  • 95
  • Thank lujop. I have all my jars in "libs" folder and I can see all those are automatically included in Android Dependencies. – ChrsitopherJ May 07 '12 at 17:14
  • No. we don't use proguard. This problem is happening without any proguard configuration. – ChrsitopherJ May 07 '12 at 17:23
  • what if i have referenced library projects and after including libs directory with jars i am getting dalvik conversion error with bunch of "already added" errors? – ZZZ Jun 26 '12 at 13:30
1

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!

das_weezul
  • 6,082
  • 2
  • 28
  • 33
0

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"

user123321
  • 12,593
  • 11
  • 52
  • 63
0

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

Diackca
  • 1
  • 1