3

我在我的项目中使用 TP。
我正在使用 TP 注入一些对象。但是当我在我的应用程序中应用 proguard 规则时。它在调试模式下工作正常但是在发布模式下给空对象我通过@Inject 注释注入的所有对象。

4

1 回答 1

2

我在我们的项目中有这个工作,除了问题 #146 中的内容之外,您还需要添加更多内容。android 支持注释库中有一个 @Keep 注释设置,可用于标记不被混淆的类,我不得不在一些 kotlin 数据类上执行此操作,因为 Retrofit 并且 kotlin-reflect 库无法播放很好的混淆。无论如何,可以在这里找到要点。此外,您可能希望明确告诉它不要混淆您告诉牙签生成非反射注册表和工厂实现的包中生成的 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.** { *; }
于 2017-11-30T19:52:38.990 回答