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

转自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
  在CODE上查看代码片 派生到我的代码片
  1. 11-15 01:46:26.818: W/System.err(21810): java.lang.RuntimeException: Missing type parameter.  
  2. 11-15 01:46:26.828: W/System.err(21810):    at da.<init>(Unknown Source)  
  3. 11-15 01:46:26.828: W/System.err(21810):    at gc.<init>(Unknown Source)  
  4. 11-15 01:46:26.828: W/System.err(21810):    at fx.f(Unknown Source)  

处理方法

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

[java]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. # Gson uses generic type information stored in a class file when working with fields. Proguard  
  2. # removes such information by default, so configure it to keep all of it.  
  3. -keepattributes Signature  
  4.   
  5. # Gson specific classes  
  6. -keep class sun.misc.Unsafe { *; }  
  7. #-keep class com.google.gson.stream.** { *; }  
  8.   
  9. # Application classes that will be serialized/deserialized over Gson  
  10. -keep class com.google.gson.examples.android.model.** { *; }  

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

[java]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. -keepclassmembers public class * implements com.android.ISaveBean {  
  2.       
  3.     private *;  
  4.    void set*(***);  
  5.    *** get*();  
  6. }  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值