By Yasin YILDIRIM


2012-03-22 10:43:02 8 Comments

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?

10 comments

@ademar111190 2013-08-19 05:15:02

I'm using GSON in a library project, so to solve this issue beyond add the GSON jar on build path, I needed declare it on my Library project manifest like as below:

<uses-library android:name="com.google.gson" />

@Natt 2013-06-13 09:52:01

  1. Right click the project, and choose Properties
  2. Go to Java Build Path-Order and Export.
  3. Tick 'Android Private Libraries'
  4. Click Project, Clean

@Gaurav Arora 2013-07-08 10:01:46

It helped me and saved my lots of hours

@clearwater 2013-12-11 12:58:38

Thanks that was the only thing that helped me

@Hpsaturn 2013-05-17 18:36:21

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!

@Srikanth 2012-04-11 12:07:41

download the GSON jar and make as class path

@Freddroid 2012-03-22 10:55:46

I faced a similar problem today.

This fixed it for me:

  • Remove all Android Library projects and external jars from the build path.
  • Create a folder named 'libs' in your project.
  • Place all external .jars in that folder, the ADT should now place them under 'Android Dependencies'.
  • Re-import all your previous Android Library projects the normal way.

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.

@JJD 2012-06-23 23:51:46

Could you please extend your post explaining how you would link sources and javadoc with this configuration?

@Freddroid 2012-06-26 12:46:05

There are some "how-to" fix sources and javadocs in the comments for this the reported issue:Link

@Georgie 2012-03-23 03:59:42

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

@CQM 2012-05-30 20:09:09

this fixed it for me, but instead of "cleaning" the project, I had to restart eclipse.

@GChorn 2014-01-09 22:06:24

@CQM, thanks for the comment, for me restarting Eclipse also worked, while cleaning the project did not.

@JaydeepW 2012-03-23 03:59:09

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

@Xavi Rigau 2012-03-22 15:13:11

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/

@Eleni 2012-03-22 10:53:29

For SDK Tools 17 you need to rename your library project's folder from "lib" to "libs" as suggested here. Also have a look at this.

@Artemis 2012-03-22 10:50:16

Check your gson library in build path. maybe gson libraty aren't not accesible.

Related Questions

Sponsored Content

18 Answered Questions

1 Answered Questions

[SOLVED] When I run the program then I face runtime issue

  • 2019-02-02 19:23:17
  • ajinkya jadhav
  • 48 View
  • 2 Score
  • 1 Answer
  • Tags:   android

1 Answered Questions

[SOLVED] I am getting the Following error when executing the code

  • 2014-05-17 06:05:45
  • munishguptamg
  • 128 View
  • 0 Score
  • 1 Answer
  • Tags:   android

2 Answered Questions

[SOLVED] AudioFlinger could not create effect, status: -22

  • 2013-01-30 11:43:04
  • Bel
  • 4030 View
  • 5 Score
  • 2 Answer
  • Tags:   android

Sponsored Content