【问题标题】:Issue in resolving nonnull and notnull symbol in looper.java解决 looper.java 中的非空和非空符号的问题
【发布时间】:2016-02-04 12:33:22
【问题描述】:

我正在开发一个安卓应用,请帮我解决依赖错误。

package android.os;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

我添加了以下依赖项:

dependencies {

    compile group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.0'
    compile 'com.android.support:multidex:1.0.1'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:support-v4:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.parse:parse-android:1.12.0'
    compile fileTree(include: '*.jar', dir: 'libs')
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:support-annotations:23.1.1'
}

【问题讨论】:

标签: android android-gradle-plugin


【解决方案1】:

从 android api 29 ('targetSdkVersion' 29) 开始,com.android.support 已移至 'androidx' 库。 在您的 Build.gradle 文件(应用级别)中,依赖项阻止使用...

依赖项{ ...

实现 'androidx.annotation:annotation:1.1.0' }

在你的 .java 文件中使用 import 如下: 导入androidx.annotation.NonNull; ...

再次构建您的项目!

【讨论】:

    【解决方案2】:

    在您的依赖项中添加以下内容

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

    另外,验证一下

    转到文件 -> 设置 -> 搜索“可为空”并验证这些设置。

    【讨论】:

    • 我收到一个错误:Avoid using + in version numbers; can lead to unpredictable and unrepeatable builds。删除了:+
    • @LuisA.Florit:您可以使用特定版本,而不是使用“+”。
    【解决方案3】:

    试试:

    import android.support.annotation.NonNull;
    

    还像其他人已经提到的那样添加 gradle build:

    dependencies {
        compile 'com.android.support:support-annotations:+'
    }
    

    【讨论】:

      【解决方案4】:

      自从 Google 在 IO17 宣布 gradle:3.0 以来,compile 配置现已弃用,应替换为 implementationapi

      所以更喜欢

      dependencies {
          ...
          implementation 'com.android.support:support-annotations:27.1.1'
          ...
      }
      

      或更高版本

      【讨论】:

        【解决方案5】:

        在您的依赖项中添加以下内容

        dependencies {
            compile 'com.android.support:support-annotations:+'
        }
        

        【讨论】:

          猜你喜欢
          • 2016-07-30
          • 1970-01-01
          • 2018-07-04
          • 2017-01-19
          • 1970-01-01
          • 2021-12-03
          • 2013-04-29
          • 1970-01-01
          • 2011-09-21
          相关资源
          最近更新 更多