我在我们的项目中有这项工作,除了问题#146之外,你还需要补充一些东西。android support annotations库中有一个@Keep注释设置,可以用来标记一个不需要模糊处理的类,我不得不在一些kotlin数据类上做这件事作为改装,kotlin reflect库无法很好地处理模糊处理。无论如何,可以找到要点
here
. 此外,您可能希望明确告诉它不要混淆您告诉Toothick生成非反射注册表和工厂实现的包中生成的FactoryRegistry类中的任何内容。
# Note that if we could use kapt to generate registries, possible to get rid of this
-keepattributes Annotation
# Do not obfuscate classes with Injected Constructors
-keepclasseswithmembernames class * {
@javax.inject.Inject (...);
}
# Do not obfuscate classes with Injected Fields
-keepclasseswithmembernames class * {
@javax.inject.Inject ;
}
# Do not obfuscate classes with Injected Methods
-keepclasseswithmembernames class * {
@javax.inject.Inject ;
}
-keep @android.support.annotation.Keep class *
-keep @javax.inject.Singleton class *
-dontwarn javax.inject.**
-dontwarn javax.annotation.**
-keep class **$$Factory { *; }
-keep class **$$MemberInjector { *; }
-adaptclassstrings
-keep class toothpick.** { *; }