Gson NoClassDefFoundError after updating ADT and SDK Tools to v17

Today I upgraded my ADT and SDK tools to v17 and my projects using the Google gons jar library started throwing NoClassDefFoundError. Here is 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?

+43
android noclassdeffounderror gson adt
Mar 22 '12 at 10:43
source share
10 answers

Today I ran into a similar problem.

This is fixed for me:

  • Remove all Android library projects and external banks from the build path.
  • Create a folder named libs in your project.
  • Put all external .jars in this folder, ADT should now put them under "Android Dependencies".
  • Reimport all previous projects into the Android library in the usual way.

The problem is that external banks are not placed in the "libs" folder by default when using the properties - Java Build Path - Add External Jar, instead they are placed in the "Linked Libraries" instead of "Android Dependencies", and this raises NoClassDefFoundError.

Please see Working with Dependencies in Android Projects for more details.

+77
Mar 22 '12 at 10:55
source share
  • Right-click the project and select "Properties"
  • Go to Java Build Path-Order and Export.
  • Check "Android Private Libraries"
  • Click "Project", "Clear"
+13
Jun 13 '13 at 9:52
source share

For SDK Tools 17, you need to rename the library project folder from "lib" to "libs", as suggested here . Also see this .

+10
Mar 22 2018-12-22T00:
source share

This site has the simplest solution that worked for me, check the box in the library in the "Order and Export" section.

http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17

+5
Mar 23 2018-12-12T00:
source share

I posted a blog post on how to fix these issues. This is due to the libraries and the changes they have made regarding how Eclipse is managing 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/

+2
Mar 22 2018-12-22T00:
source share

Check order and select

 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 the 'libs' directory) Others

Worked for me!

+2
May 17 '13 at 18:36
source share

Check your gson library in the build path. gson libraty may not be available.

0
Mar 22 '12 at 10:50
source share

This is the official link provided by Android Devs on Google. Go through the article if you encounter a NoClassDefFoundException after updating the plugin and / or SDK

https://plus.google.com/115995639636688350464/posts/38o8ZA6xQK4

0
Mar 23 2018-12-12T00:
source share

load the GSON jar and make as a class path

0
Apr 11 2018-12-12T00:
source share

I use GSON in the library project, so to solve this problem, in addition to adding the GSON bar in the build path, I needed to declare it in the manifest of the library project, as shown below:

 <uses-library android:name="com.google.gson" /> 
0
Aug 19 '13 at 5:15
source share



All Articles