如何修复 android studio 3 中的“找不到符号类 Nullable"错误 [英] How to fix 'cannot find symbol class Nullable' error in android studio 3

查看:92
本文介绍了如何修复 android studio 3 中的“找不到符号类 Nullable"错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆