2

I write a android app in Eclipse and use run command on my cellphone.

It's run success on my cellphone.

But I use [Android Tools -> Export Signed Application Package...] to export my app.

Then use [adb install] to install apk on my cellphone and run.

And I got the error message:

07-22 11:20:43.537: E/AndroidRuntime(20216): Caused by: java.lang.ClassNotFoundException: com.mytest.MyActivity in loader dalvik.system.PathClassLoader[/data/app/com.mytest-1.apk]

In [Java Build Path -> Order and Export], I have been selected all.

In AndroidManifest.xml, the application attribute doesn't have android:name.

I don't know how to solve this problem.

I'm success use Eclipse run on my cellphone, why run error when I export the app?

please help me, thanks!!

Tony
  • 187
  • 1
  • 3
  • 14

3 Answers3

5

I had same issue, after 2 hours of research I managed to fix this problem by deleting "bin" and "gen" folders and rebuilding project.

Tadas Valaitis
  • 870
  • 10
  • 11
4

There seems to multiple reasons for this happening from what I have researched. Do you have a lib folder? if so change it to "libs".

Do you have proguard enabled? If so that may cause the problem. Also try unchecking the "Android #.#.#" and "Android Dependencies" in your Build Path, Order and Export.

Check out this thread which has a bunch of other possible solutions, a lot of them deal with setting the proper ActivityName in the manifest file. java.lang.ClassNotFoundException on working app

If those solutions still don't solve the problem try these threads.

Android: Unable to instantiate activity / ClassNotFoundException

ClassNotFoundException Android

Community
  • 1
  • 1
Gatekeeper
  • 6,708
  • 6
  • 27
  • 37
  • Thanks for your help~~ I'm updating my SDK Tools(Rev. 20) and SDK Platform-tools(Rev. 12) and ADT, then solved. – Tony Jul 22 '12 at 05:07
0

What I had to do is just re-do the building/exporting process with no modification to the code whatsoever. It worked for me, which I did was to export it two times. On my first export, the build APK has lower file size and the second export (with no any modification to the code/configuration) produced a slightly larger file size (about 200KB diff).

This bug in building is really costly, kills you in front of your manager, and should be really fixed by Android/Eclipse team. Kind of sucks

patrickjason91
  • 865
  • 11
  • 20