我不确定为什么这个特定的库会给我带来麻烦,而其他人却没有。我做了以下尝试缩小范围:
1.) 在 Eclipse 中,新的 Android 项目 2.) 将 gson-1.7.1.jar 复制到 lib/ 3.) 右键单击 gson-1.7.1.jar,添加到构建路径 4.) 将此添加到样板主要活动: 格森格森; 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)