繁体   English   中英

R8 混淆导致 @PropertyName 无法工作导致 DatabaseException:找到两个有冲突的 getter 或字段

[英]R8 obfuscation results in @PropertyName not working causing DatabaseException: Found two getters or fields with conflicting

只有当我混淆我的应用程序时,我才会收到以下错误:

com.google.firebase.database.DatabaseException: Found two getters or fields with conflicting case sensitivity for property: data`

这适用于以小写字母开头但存储在以大写字母开头的 firebase 中的 class 属性 - 例如用@PropertyName("Data")注释的val data

有两个 firebase 依赖模块(firebase-database 和 firebase-firestore)都包含@PropertyName并且当我更改我的 class 导入时:

import com.google.firebase.database.PropertyName

import com.google.firebase.firestore.PropertyName

然后崩溃消失但未获取数据。

我不允许共享数据库详细信息,但 model 具有以下结构:

import com...ResponseBase
import com.google.firebase.database.IgnoreExtraProperties
import com.google.firebase.database.PropertyName

@IgnoreExtraProperties
data class TxResponse constructor(
    @PropertyName("Data")
    val data: Data = Data(),
    @PropertyName("AnId")
    val anId: String = "",
    @PropertyName("AResult")
    val aResult: String = "",
    @PropertyName("moreData")
    val moreData: MoreData = MoreData()
) : ResponseBase()

@IgnoreExtraProperties
data class Data constructor(
    @PropertyName("SomeId")
    val someId: String = "",
    @PropertyName("Label")
    val label: String = "",
    ...
)

@IgnoreExtraProperties
data class MoreData(
    @PropertyName("Code")
    val code: Long = 0
)

仅作为背景,我keep模型和 firebase 类。 我使用的是 firebase-firestore 22.0.0 版和 firebase-database-ktx 19.5.1 版。 使用最新版本并不能解决问题。 不幸的是,我无法更改数据库。

任何帮助将不胜感激!

这不是解释,我不明白这一点,但它可能对其他人有所帮助......

这是导致异常的行:

-keep class com...response.** { *; }

如果我删除它,异常就会消失,但我仍然需要保留这些字段,解决方案是改用这个规则

-keepnames class com...response.** { <fields>; }

但是,第一条规则更接近官方文档中推荐的规则,并且是更广泛的保留规则:

https://firebase.google.com/docs/database/android/start#proguardhttps://www.guardsquare.com/en/products/proguard/manual/refcard

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM