转自http://blog.youkuaiyun.com/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来解析数据很空间出现下面异常
- 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 文件,增加
- # 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
- -keepclassmembers public class * implements com.android.ISaveBean {
-
- private *;
- void set*(***);
- *** get*();
- }