Nas*_*sib 5 android proguard minify
我在我的项目中使用 FirebaseFirestore。当我处于调试模式时,minifyEnabled FALSE,应用程序运行得很好,但是当我构建签名的.apk时,minifyEnabled TRUE,它无法按我的预期工作。即它不从 firebase Firestore 加载数据。
我应该写什么 KEEP 语句来排除 FIREBASE FIRESTORE 和 Glide 类的缩小?
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-firestore:19.0.0'
implementation 'com.google.firebase:firebase-ads:17.2.0'
}
Run Code Online (Sandbox Code Playgroud)
解决方案: ProGuard 重命名了几乎每个类。它重命名了我的模型类(pojo),我用它来封装 Firestore 的数据,而 firestore 只识别该名称,在我的例子中是“Upload”。
但是当混淆器重命名它时,它将“Upload”类命名为“j”,并且firestore SDK无法识别“j”。
这就是问题所在。
我@Keep在“Upload”类中添加了“”注释,我的问题得到了解决。
@Keep
public class Upload{
.....
.....
}
Run Code Online (Sandbox Code Playgroud)
建议:
您还应该@Keep为Room Entity Classes 和Retrofit data Classes添加此注释