我的代码已经运行了一年多,在其他地方更改了一些代码后,我没有更改MainActivity
中的任何代码,这是第一种形式。我现在得到这个error: java.lang.reflect.InvocationTargetException
然后java.lang.NoClassDefFoundError: com/google/gson/Gson
尝试这个:
Gson gson = new Gson();
我有其他程序,我使用Gson,它们工作正常。我的项目中的libs文件夹中有gson-2.2.4。我已经尝试了几个小时阅读所有其他类似的问题,但我被卡住了。 猫日志:
06-06 01:47:25.935: I/System.out(4393): debugger has settled (1304)
06-06 01:47:26.120: E/dalvikvm(4393): Could not find class 'com.google.gson.Gson', referenced from method com.comcasystems.routedriver.MainActivity.onCreate
06-06 01:47:26.120: W/dalvikvm(4393): VFY: unable to resolve new-instance 133 (Lcom/google/gson/Gson;) in Lcom/comcasystems/routedriver/MainActivity;
06-06 01:47:26.120: D/dalvikvm(4393): VFY: replacing opcode 0x22 at 0x000b
06-06 01:47:26.120: D/dalvikvm(4393): DexOpt: unable to opt direct call 0x0206 at 0x0d in Lcom/comcasystems/routedriver/MainActivity;.onCreate
06-06 01:47:26.170: E/dalvikvm(4393): Could not find class 'com.google.gson.Gson', referenced from method com.comcasystems.routedriver.MainActivity$1.handleMessage
06-06 01:47:26.170: W/dalvikvm(4393): VFY: unable to resolve new-instance 133 (Lcom/google/gson/Gson;) in Lcom/comcasystems/routedriver/MainActivity$1;
06-06 01:47:26.175: D/dalvikvm(4393): VFY: replacing opcode 0x22 at 0x0024
答案 0 :(得分:2)
请注意您在Java构建路径中包含了Gson库,并检查proguard是否已正确配置:
# proguard configuration for Gson
-keepattributes Signature
-keep public class com.google.gson
-keep class sun.misc.Unsafe { *; }
-keep class com.comcasystems.routedriver.jsonclasses.** { *; }
注意:最后一个条目只是Json类的符号占位符,可以防止它们被混淆。您必须在此处列出所有受影响的类。
希望这有帮助......干杯!