首页 > 解决方案 > Android SharedPreferences 类使用错误的注解引用

问题描述

我更新了旧 Android 项目的build.gradle文件以使用新的androidx实现引用而不是旧的编译引用。在整个应用程序中,我必须用新的androidx.annotation.Nullable替换所有导入的android.support.annotation.Nullable。这似乎适用于应用程序自己的自定义代码库。

但是,该应用还有一个SharedPreferences类,它使用android.content.SharedPreferences类。后一个一直引用旧的android.annotation.Nullable现在给我一个“无法解析符号”错误。我在 build.gradle 文件中包含了以下实现,我不知道我是否遗漏了任何东西来保持它应该正常工作?

implementation "androidx.appcompat:appcompat:1.0.0"
implementation "com.google.android.material:material:1.0.0-rc01"
implementation "androidx.legacy:legacy-support-v4:1.0.0"
implementation 'me.dm7.barcodescanner:zxing:1.9.13'
implementation 'me.dm7.barcodescanner:zbar:1.8.4'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.github.clans:fab:1.6.2'
implementation 'androidx.annotation:annotation:1.1.0'

标签: androidandroid-studioandroidx

解决方案


推荐阅读