添加 Room Library 时 android Studio 中的 Gradle 构建错误

Gradle building error in android Studio when adding Room Library

提问人:Meti 提问时间:6/23/2021 最后编辑:Aniruddh PariharMeti 更新时间:6/25/2021 访问量:323

问:

当我在项目中添加 Room 库时,我的文件中出现错误build.gradle

这是我的build.gradle

plugins {
    id 'com.android.application'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

    defaultConfig {
        applicationId "com.example.mvp_sample_todolist"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"
        vectorDrawables.useSupportLibrary(true)

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}

dependencies {

    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    implementation "androidx.room:room-runtime:2.3.0"
    annotationProcessor "androidx.room:room-compiler:2.3.0"


}

以下是我收到的错误

Execution failed for task ':app:javaPreCompileDebug'.
> Could not resolve all files for configuration ':app:debugAnnotationProcessorClasspath'.
   > Could not find annotation-1.1.0.jar (androidx.annotation:annotation:1.1.0).
     Searched in the following locations:
         https://dl.google.com/dl/android/maven2/androidx/annotation/annotation/1.1.0/annotation-1.1.0.jar

我什至试图删除项目的gradle文件,但仍然无法正常工作。
如果有人知道如何解决此错误,请提供帮助。

android-gradle-plugin 依赖

评论

0赞 Dominik Wuttke 6/23/2021
您缺少“kapt”developer.android.com/jetpack/androidx/releases/room#kts
0赞 Meti 6/23/2021
我正在使用 Java,所以我无法设置“kapt”
0赞 Amin 6/23/2021
正如我所看到的,你是伊朗人,这可能是由于制裁,使用像 ProtonVPN 这样的好 vpn 或像 Freedom of Devs 这样的代理
0赞 Meti 6/23/2021
我设置了代理,但它没有做出不同的@Amin

答: 暂无答案