错误:包 com.android.annotations 不存在

新手上路,请多包涵

我有以下课程

import com.android.annotations.NonNullByDefault;

@NonNullByDefault
public final class Log {
    ...
}

这是我的 build.gradle 文件(省略了一些部分)

 apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion '24.0.1'

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 2
        versionName "0.2"
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }

}

dependencies {
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support:support-annotations:25.0.0'
    compile 'com.android.support:design:25.0.0'
}

在 Android Studio 中,我的班级没有发出警告

在此处输入图像描述

但是,当我尝试构建和运行我的应用程序时,我从 gradle 收到此错误

Information:Gradle tasks [:app:clean, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies, :app:assembleDebug]
Warning:[options] bootstrap class path not set in conjunction with -source 1.7
/home/puter/git-repos/TaskManager3/app/src/main/java/com/treemetrics/taskmanager3/util/Log.java
Error:(3, 31) error: package com.android.annotations does not exist
Error:(7, 2) error: cannot find symbol class NonNullByDefault
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Information:BUILD FAILED
Information:Total time: 21.021 secs
Information:3 errors
Information:1 warning
Information:See complete output in console

原文由 Moses 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 544
1 个回答

只需安装(它会自动修复)

 npm install --save-dev jetifier <--------avoid if aleardy installed start from below lines
npx jetify

然后运行

npx cap sync

最后

  npx react-native run-android



原文由 ßãlãjî 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题