Today I updated my ADT and SDK Tools to v17 and my projects using Google's gson jar library started to throw NoClassDefFoundError. Here's the logcat output:
> 03-22 12:30:58.941: E/AndroidRuntime(21672): FATAL EXCEPTION: main
> 03-22 12:30:58.941: E/AndroidRuntime(21672):
> java.lang.NoClassDefFoundError: com.google.gson.Gson 03-22
> 12:30:58.941: E/AndroidRuntime(21672): at
> com.matriksdata.conn.XRequestHandler.connect(XRequestHandler.java:35)
> 03-22 12:30:58.941: E/AndroidRuntime(21672): at
> com.matriksdata.conn.XRequestHandler.makeRequest(XRequestHandler.java:
> 29) 03-22 12:30:58.941: E/AndroidRuntime(21672): at
> com.matriksdata.bavul.XBaseWithConnectionActivity.makeRequest(XBaseWithConnectionActivity.java:
> 46) 03-22 12:30:58.941: E/AndroidRuntime(21672): at
> com.matriksdata.ui.login.SplashScreenActivity.onCreate(SplashScreenActivity.java:
> 36) 03-22 12:30:58.941: E/AndroidRuntime(21672): at
> android.app.Activity.performCreate(Activity.java:4465) 03-22
> 12:30:58.941: E/AndroidRuntime(21672): at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
> 1049) 03-22 12:30:58.941: E/AndroidRuntime(21672): at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
> 1919) 03-22 12:30:58.941: E/AndroidRuntime(21672): at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
> 1980) 03-22 12:30:58.941: E/AndroidRuntime(21672): at
> android.app.ActivityThread.access$600(ActivityThread.java:122) 03-22
> 12:30:58.941: E/AndroidRuntime(21672): at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
> 03-22 12:30:58.941: E/AndroidRuntime(21672): at
> android.os.Handler.dispatchMessage(Handler.java:99) 03-22
> 12:30:58.941: E/AndroidRuntime(21672): at
> android.os.Looper.loop(Looper.java:137) 03-22 12:30:58.941:
> E/AndroidRuntime(21672): at
> android.app.ActivityThread.main(ActivityThread.java:4340) 03-22
> 12:30:58.941: E/AndroidRuntime(21672): at
> java.lang.reflect.Method.invokeNative(Native Method) 03-22
> 12:30:58.941: E/AndroidRuntime(21672): at
> java.lang.reflect.Method.invoke(Method.java:511) 03-22 12:30:58.941:
> E/AndroidRuntime(21672): at com.android.internal.os.ZygoteInit
> $MethodAndArgsCaller.run(ZygoteInit.java:784) 03-22 12:30:58.941:
> E/AndroidRuntime(21672): at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) 03-22
> 12:30:58.941: E/AndroidRuntime(21672): at
> dalvik.system.NativeStart.main(Native Method)
any ideas?
I faced a similar problem today.
This fixed it for me:
The issue is that external jars are not placed in the 'libs' folder by default when using Properties - Java Build Path- Add External Jar, instead they are placed under 'Referenced Libraries' instead of 'Android Dependencies' and this causes the NoClassDefFoundError.
Please, check Dealing with dependencies in Android projects for more details.
This site has the simplest solution which worked for me, select the library's checkbox under "Order and Export".
http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17
Check order and selects in
Project->Properties->Java build path->Order and Export:
Order and select:
select Google APIs (optional)
select Dependencies
select Android Private Libraries
[-] src
[-] gen
And in the tab libraries:
Dependencies Private libraries (jars in 'libs' directory) Others
Worked for me!
I created a quick post in my blog explaining how to fix those problems. It has to do with libraries and a change they made on how Eclipse manages libraries now. You can check it here if you want: http://xrigau.wordpress.com/2012/03/22/fix-some-problems-with-libraries-in-the-adt-17-plugin-10/
下载GSON jar并作为类路径
我在图书馆项目中使用GSON,因此要解决此问题,而不仅仅是在构建路径上添加GSON jar,我需要在我的图书馆项目清单中声明它,如下所示:
<uses-library android:name="com.google.gson" />
Check your gson library in build path. maybe gson libraty aren't not accesible.
This is an official link provided by Android Devs at Google. Go through the article if you are facing NoClassDefFoundException after updating the plugin and/or SDK
https://plus.google.com/115995639636688350464/posts/38o8ZA6xQK4
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.