Android Studio更新后无法解析符号"NonNull" [英] Cannot resolve symbol 'NonNull' after Android Studio update

查看:1353
本文介绍了Android Studio更新后无法解析符号"NonNull"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近更新了Android Studio.之后,似乎不再能够解析某些支持注释,例如@NonNull@Nullable.在更新之前,它确实工作正常.但是,所有内容仍在编译中,并且我能够执行Code,但仍然显示在导入时符号无法解析的消息.

I recently updated Android Studio. Afterwards it seems to no longer being able to resolve some support annotations, such as @NonNull or @Nullable. It did work just fine before updating. However, everything is still compiling and I am able to execute Code, but still it shows the symbol cannot be resolved message at my imports.

到目前为止我已经尝试过的:

What I have already tried so far:

  1. 在build.gradle中包含了依赖项(模块:应用程序):

  1. Included the dependency in build.gradle (Module: Application):

compile 'com.android.support:support-annotations:27.0.0'

  • 我已使缓存无效并重新启动
  • 清洁和重建项目
  • (编辑)同步Gradle
  • 我不知道为什么这不起作用,非常感谢您的帮助.

    I have no idea why this is not working and would really appreciate your help.

    推荐答案

    从android api 29('targetSdkVersion'29)开始,com.android.support已移至"androidx"库.

    As of android api 29 ('targetSdkVersion' 29) com.android.support has been moved to 'androidx' library.

    在您的build.gradle文件(应用级别)中,依赖项被阻止使用...

    In your build.gradle file(app level), dependencies block use...

    dependencies{ 
        ...
        implementation 'androidx.annotation:annotation:1.1.0' 
    }
    

    在您的.java文件中,使用import,如下所示:

    And in your .java files use import as follows:

    import androidx.annotation.NonNull;
    

    再次构建您的项目!

    这篇关于Android Studio更新后无法解析符号"NonNull"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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