Firebase 找不到引用的方法

Firebase can't find referenced method

我在使用 ProGuard 构建 APK 时遇到以下错误:

ProGuard 使用的是默认的 proguardfile,但这个问题刚刚出现。我该如何解决?

如果您使用 Firebase 身份验证,则需要在混淆文件中添加以下行:

-keepattributes Signature
-keepattributes *Annotation*

上面的文档 link 是:Optional: Configure ProGuard

此外,根据文档如果您使用DataSnapshot.getValue(Class)或DatabaseReference.setValue(Object)来读写数据,您需要考虑混淆后如何序列化和反序列化您的模型对象 然后,您需要添加以下内容:

# Add this global rule
-keepattributes Signature

# This rule will properly ProGuard all the model classes in
# the package com.yourcompany.models. Modify to fit the structure
# of your app.
  -keepclassmembers class com.yourcompany.models.** {
*;
}

这是文档的 link:Set up Firebase Realtime Database for Android