How to fix the “NoClassDefFoundError” with ADT 17
2012-05-11 11:03
274 查看
So I updated my SDK and ADT to version 17 and once
again I got a big problem :)
Every project I have which use JAR libraries could still be built without problems but as soon as they start on the phone, they crashed with the following error :
I asked Xavier
Ducrohet and Tor
Norbye (both working on the ADT plugin) on Google+ about
the error and they linked to this
page which explains how to solve the problem but is not ultra clear (at least for me).
So here is the same solution but explained with screenshots so we can see more easily what changed :
From left to right, we have :
My project with ADT 16 (the small graphic changes are due to the fact the left image is from Eclipse
Windows while the 2 on the right are from Eclipse Mac)
My project with ADT 17 before the fix
My project with ADT 17 after the fix
We can see :
In blue,
the changes due to the patch (more info on this at the end of this post)
In red,
the changes for the fix
What I did to fix the bug was :
Remove the libraries from the standard Java build path :
Right click on the project name > Properties > Java Build Path > tab Libraries > remove everything except the “Android X.X” (2.3.3
in my case) and the “Android Dependencies”
Rename the libraries folder from “lib” to “libs”
By doing that, all the libraries in the folder “libs” are found by the Android plugin and are added to the “Android Dependencies” item of the project
Clean the project (not exactly needed)
You are good to go !
This problem is due to the fact that libraries are not managed the same way with the new ADT build.
Instead of having 2 different managements of libraries (one for Android Library Projects, one for the standard jars), now both are merged into the Android Dependencies item.
Other info, the annotations.jar file is for the new lint Java annotations (more info here : http://tools.android.com/recent/ignoringlintwarnings)
Besides this small problem, the ADT version 17 looks really good and I love the new things added to the lint checks !!
[Update]
The DroidUX Team found another solution to fix the problem. I didn’t test it personally but it don’t
see why it shouldn’t work :
Hi,
Just to add to the solution:
If you have references to jars that are not in the ‘libs’ folder, for example if you use ‘classpath variable’, you can resolve the
with the new ADT 17 by exporting the references.
To export the references: simply go to “Properties > Java Build Path > Order and Export”, and check all the references you want exported.
Cheers,
DroidUX Team
[/Update]
参考链接:
http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17
http://blog.csdn.net/aomandeshangxiao/article/details/7552109
again I got a big problem :)
Every project I have which use JAR libraries could still be built without problems but as soon as they start on the phone, they crashed with the following error :
03-21 19:20:56.455: E/AndroidRuntime(24471): FATAL EXCEPTION: main 03-21 19:20:56.455: E/AndroidRuntime(24471): java.lang.NoClassDefFoundError: org.acra.ACRA 03-21 19:20:56.455: E/AndroidRuntime(24471): at com.foxykeep.myproject.HomeActivity.onCreate(MyProjectApplication.java:127) 03-21 19:20:56.455: E/AndroidRuntime(24471): at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:969) 03-21 19:20:56.455: E/AndroidRuntime(24471): at android.app.ActivityThread.handleBindApplication(ActivityThread.java:3925) 03-21 19:20:56.455: E/AndroidRuntime(24471): at android.app.ActivityThread.access$1300(ActivityThread.java:122) 03-21 19:20:56.455: E/AndroidRuntime(24471): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1184) 03-21 19:20:56.455: E/AndroidRuntime(24471): at android.os.Handler.dispatchMessage(Handler.java:99) 03-21 19:20:56.455: E/AndroidRuntime(24471): at android.os.Looper.loop(Looper.java:137) 03-21 19:20:56.455: E/AndroidRuntime(24471): at android.app.ActivityThread.main(ActivityThread.java:4340) 03-21 19:20:56.455: E/AndroidRuntime(24471): at java.lang.reflect.Method.invokeNative(Native Method) 03-21 19:20:56.455: E/AndroidRuntime(24471): at java.lang.reflect.Method.invoke(Method.java:511) 03-21 19:20:56.455: E/AndroidRuntime(24471): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) 03-21 19:20:56.455: E/AndroidRuntime(24471): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 03-21 19:20:56.455: E/AndroidRuntime(24471): at dalvik.system.NativeStart.main(Native Method)
I asked Xavier
Ducrohet and Tor
Norbye (both working on the ADT plugin) on Google+ about
the error and they linked to this
page which explains how to solve the problem but is not ultra clear (at least for me).
So here is the same solution but explained with screenshots so we can see more easily what changed :
From left to right, we have :
My project with ADT 16 (the small graphic changes are due to the fact the left image is from Eclipse
Windows while the 2 on the right are from Eclipse Mac)
My project with ADT 17 before the fix
My project with ADT 17 after the fix
We can see :
In blue,
the changes due to the patch (more info on this at the end of this post)
In red,
the changes for the fix
What I did to fix the bug was :
Remove the libraries from the standard Java build path :
Right click on the project name > Properties > Java Build Path > tab Libraries > remove everything except the “Android X.X” (2.3.3
in my case) and the “Android Dependencies”
Rename the libraries folder from “lib” to “libs”
By doing that, all the libraries in the folder “libs” are found by the Android plugin and are added to the “Android Dependencies” item of the project
Clean the project (not exactly needed)
You are good to go !
This problem is due to the fact that libraries are not managed the same way with the new ADT build.
Instead of having 2 different managements of libraries (one for Android Library Projects, one for the standard jars), now both are merged into the Android Dependencies item.
Other info, the annotations.jar file is for the new lint Java annotations (more info here : http://tools.android.com/recent/ignoringlintwarnings)
Besides this small problem, the ADT version 17 looks really good and I love the new things added to the lint checks !!
[Update]
The DroidUX Team found another solution to fix the problem. I didn’t test it personally but it don’t
see why it shouldn’t work :
Hi,
Just to add to the solution:
If you have references to jars that are not in the ‘libs’ folder, for example if you use ‘classpath variable’, you can resolve the
NoClassDefFoundErrorissue
with the new ADT 17 by exporting the references.
To export the references: simply go to “Properties > Java Build Path > Order and Export”, and check all the references you want exported.
Cheers,
DroidUX Team
[/Update]
参考链接:
http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17
http://blog.csdn.net/aomandeshangxiao/article/details/7552109
相关文章推荐
- How to fix the “NoClassDefFoundError” with ADT 17
- How to fix the dreaded "java.lang.OutOfMemoryError: PermGen space" exception (classloader leaks)
- Q&A: HOW TO FIX XCODE’S "USED AS THE NAME OF THE PREVIOUS PARAMETER" WARNING
- how to fix the frame size?
- How to fix the issue that GEM_HOME and/or GEM_PATH not set issue for rvm in mac version 10.12
- How to fix the dreaded "java.lang.OutOfMemoryError- PermGen space" exception (classloader leaks)
- how to fix the problem when you install matlab on *nix-- "libXp.so.6 : cannot open "
- How to fix “The system is running in low-graphics mode” Ubuntu 17.04 or 16.04
- How do I fix the linker error in project upgraded from VS2010 to VS2013 where the linker is looking
- How to fix the gray screen bug in VirtualBox
- 继续摘抄:How to fix Apache – “Could not reliably determine the server’s fully qualified domain name, using 127.0.1.1 for ServerName”
- how to fix the problem when you install matlab on *nix-- "libXp.so.6 : cannot open "
- How to fix the bug 640*480 resolution only when install ubuntu 14.04 on a old laptop?
- how to fix the assembly problem when project A call project B as reference
- How to fix OpenGL ES application crashes when moving to the background
- How to Fix “ERROR : Could not find tsearch2.sql file” While Starting the PostgreSQL Database
- How to fix the problem 'Your CPU supports instructions that this TensorFlow binary was not compiled'
- how to fix "The App Name you entered has already been used"
- How to fix the python problem 'xxx() takes exactly one argument'
- How to fix the dreaded "java.lang.OutOfMemoryError: PermGen space" exception (classloader leaks)