GreenDao2 配置混淆错误解决

配置了混淆后已启动App,就直接Cash。log信息报如下错误:

Caused by: java.lang.NoSuchFieldException: TABLENAME

检查了proguard-rules文件并且按照官方给出方法去配置混淆规则


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
### greenDAO 3
- keepclassmembers class * extends org . greenrobot . greendao . AbstractDao {
public static java . lang . String TABLENAME ;
}
- keep class * * $ Properties
# If you do not use SQLCipher:
- dontwarn org . greenrobot . greendao . database . * *
# If you do not use RxJava:
- dontwarn rx . * *
 
### greenDAO 2
- keepclassmembers class * extends de . greenrobot . dao . AbstractDao {
public static java . lang . String TABLENAME ;
}
- keep class * * $ Properties

但是错误依旧报错。后来通过 Stack Overflow 成功解决问题 
混淆规则如下:

-keep class de.greenrobot.dao.** {*;}
-keepclassmembers class * extends de.greenrobot.dao.AbstractDao {
    public static Java.lang.String TABLENAME;
}
-keep class **$Properties
 
  
//增加如下:
-keep class data.db.dao.*$Properties {
    public static ;
}
-keepclassmembers class data.db.dao.** {
    public static final ;
  }

你可能感兴趣的:(Android开发)