您的位置:首页 > 移动开发 > Android开发

android 使用proguard 代码混淆后,出现异常 Missing type parameter.

2016-10-29 17:04 579 查看
转自http://blog.csdn.net/zengxx1989/article/details/18318169

关于Android 的代码混淆,现在实现非常装简单,只需要在文件 project.properties 中打开,去掉前面的#号

proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt

调试正常,但发布以后出现  Java.lang.RuntimeException: Missing type parameter 异常

但是打开这个功能,同时又使用了gson来解析数据很空间出现下面异常

[java] view
plain copy

 





11-15 01:46:26.818: W/System.err(21810): java.lang.RuntimeException: Missing type parameter.  

11-15 01:46:26.828: W/System.err(21810):    at da.<init>(Unknown Source)  

11-15 01:46:26.828: W/System.err(21810):    at gc.<init>(Unknown Source)  

11-15 01:46:26.828: W/System.err(21810):    at fx.f(Unknown Source)  

处理方法

修改工程目录下的 proguard-project.txt 文件,增加

[java] view
plain copy

 





# Gson uses generic type information stored in a class file when working with fields. Proguard  

# removes such information by default, so configure it to keep all of it.  

-keepattributes Signature  

  

# Gson specific classes  

-keep class sun.misc.Unsafe { *; }  

#-keep class com.google.gson.stream.** { *; }  

  

# Application classes that will be serialized/deserialized over Gson  

-keep class com.google.gson.examples.android.model.** { *; }  

然后对 相应的实体类也可进行keep

[java] view
plain copy

 





-keepclassmembers public class * implements com.android.ISaveBean {  

      

    private *;  

   void set*(***);  

   *** get*();  

}  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐