我在我的项目中使用了 TP。
我正在使用 TP 注入(inject)一些对象。但是当我在我的应用程序中应用 proguard 规则时。它在 Debug模式下工作正常但是在 Release模式下为空对象提供我通过@Inject 注释注入(inject)的所有对象。
最佳答案
我在我们的项目中有这个工作,除了 Issue #146 中的内容之外,您需要添加更多内容。 android支持注解库中有一个@Keep注解设置,可用于标记一个类不被混淆,我不得不在一些kotlin数据类上这样做,因为Retrofit和kotlin-reflect库无法播放很好的混淆。无论如何,可以找到要点here .此外,您可能希望明确告诉它不要混淆您告诉 toothpick 生成非反射注册表和工厂实现的包中生成的 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.** { *; }
关于android - 如何使用proguard牙签规则?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47074752/