首页 > 解决方案 > 依赖项更新后,Firebase“不覆盖任何内容”

问题描述

在将依赖项更新到最新版本(核心、身份验证、数据库......)后,我们在较旧的(2018 年)生产中的 Android 应用程序中出现 500 多个错误。

例如

"Object is not abstract and does not implement abstract member @PublicApi public abstract fun onDataChange(@NonNull p0: DataSnapshot): Unit defined in com.google.firebase.database.ValueEventListener"
"Type mismatch: inferred type is String? but String was expected"
"Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type DatabaseReference?"
"Smart cast to 'String' is impossible, because 'order.locationId' is a mutable property that could have been changed by this time"
"Type inference failed: Cannot infer type parameter K in inline operator fun <K, V> MutableMap<K, V>.set(key: K, value: V): Unit"
....

在这个世界上,我们没有办法一行一行地删除“?” 或添加“!!” 在整个项目中,更不用说测试和推动生产更新.....

有没有办法修复它,或者我们应该坚持使用 2018 年依赖项和 SDK 27,因为,你知道,这只是谷歌的常见做法

编辑:

修复正在删除“?” 从被覆盖的方法参数中,在项目中的 100 多个地方都是一样的

修复是添加'!!' 映射键 "products!![it.key!!]" 因为现在它不想为空

修复正在添加“?” 在父 "ref.parent?.child..." 之后,因为现在它希望是可空的,或者用 '!!' 断言的非空

修复是添加'!!' 在第一个子键“.child(vehicleKey!!)...”等...

标签: androidfirebasegradledependencies

解决方案


推荐阅读