问题描述
我正在使用android studio 3.2,并且想在我的空白类中使用SQLiteOpenHelper.当我运行项目Java编译器时返回错误:找不到符号类Nullable
i'm using android studio 3.2 , and want to use SQLiteOpenHelper in my blank class . when i have run project java compiler return error : cannot find symbol class Nullable
public class Db extends SQLiteOpenHelper {
public Db(@androidx.annotation.Nullable Context context, @androidx.annotation.Nullable String name, @androidx.annotation.Nullable SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
}}
我也使用了此实现
implementation 'com.android.support:support-annotations:24.2.0'
我单击了使缓存无效",然后在文件菜单上重新启动并重建项目,但仍然发生错误
I clicked Invalidate caches and restart on file menu and rebuild project but error still occurs
提前谢谢
推荐答案
使用:
implementation 'androidx.annotation:annotation:1.1.0'
如果实现com.android.support:support-annotations
,则需要使用android.support.annoation.Nullable
.
If you implement com.android.support:support-annotations
, then you need to use android.support.annoation.Nullable
.
如果您不完全限定名称,则简单得多,而只需使用@Nullable
即可.然后,Android Studio将为您提供可用的导入.
It's a lot easier if you don't fully qualify the names, and just use @Nullable
instead. Android Studio will then give you available imports.
如果您实际上针对的是API 24(如您列出的实现所针对的那样),则根本无法使用AndroidX. AndroidX要求targetSdkVersion
为28或更高.
If you are actually targeting API 24, like the implementation you list says you are, you simply can't use AndroidX. AndroidX requires a targetSdkVersion
of 28 or higher.
这篇关于如何修复Android Studio 3中的'找不到符号类为Nullable'的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!