Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
141 views
in Technique[技术] by (71.8m points)

android - Gson NoClassDefFoundError after ADT and SDK Tools update to v17

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?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...