我不确定为什么这个特定的lib会在别人没有的时候给我带来麻烦。我做了以下尝试缩小范围:
1。)在Eclipse中,新的Android项目 2.)将gson-1.7.1.jar复制到lib / 3.)右键单击gson-1.7.1.jar,添加到构建路径 4.)将其添加到锅炉板主要活动中:Gson gson; 5.)项目在运行时抛出此异常:
04-14 13:50:23.366: E/AndroidRuntime(1020): FATAL EXCEPTION: main
04-14 13:50:23.366: E/AndroidRuntime(1020): java.lang.NoClassDefFoundError: com.google.gson.Gson
04-14 13:50:23.366: E/AndroidRuntime(1020): at com.nerdsoft.client.GsonTestActivity.onCreate(GsonTestActivity.java:17)
04-14 13:50:23.366: E/AndroidRuntime(1020): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-14 13:50:23.366: E/AndroidRuntime(1020): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-14 13:50:23.366: E/AndroidRuntime(1020): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-14 13:50:23.366: E/AndroidRuntime(1020): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-14 13:50:23.366: E/AndroidRuntime(1020): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-14 13:50:23.366: E/AndroidRuntime(1020): at android.os.Handler.dispatchMessage(Handler.java:99)
04-14 13:50:23.366: E/AndroidRuntime(1020): at android.os.Looper.loop(Looper.java:123)
04-14 13:50:23.366: E/AndroidRuntime(1020): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-14 13:50:23.366: E/AndroidRuntime(1020): at java.lang.reflect.Method.invokeNative(Native Method)
04-14 13:50:23.366: E/AndroidRuntime(1020): at java.lang.reflect.Method.invoke(Method.java:521)
04-14 13:50:23.366: E/AndroidRuntime(1020): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-14 13:50:23.366: E/AndroidRuntime(1020): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-14 13:50:23.366: E/AndroidRuntime(1020): at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:4)
将您的lib
文件夹名称更改为libs
并重新运行。