【问题标题】:How do i fix this error "Could not find android.room:room-compiler:2.2.4."如何修复此错误“找不到 android.room:room-compiler:2.2.4。”
【发布时间】:2020-02-29 22:24:11
【问题描述】:

我正在 Kotlin 中进行一个测试项目,该项目使用带有空间的 MVVM 架构。 为项目添加依赖项和库后,项目构建成功,但是当我尝试运行应用程序时,它显示此错误:

Could not find android.room:room-compiler:2.2.4.

在以下位置搜索:

这是我的build.gradle 应用级别:

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

//kotlin Kapt and navigation safeargs plugin
apply plugin: 'kotlin-kapt'

apply plugin: "androidx.navigation.safeargs"

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.cruxrepublic.mvvmapplication"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'


//    Retrofit and Gson
    implementation 'com.squareup.retrofit2:retrofit:2.7.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.7.0'

//    kotlin Coroutines
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.1"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.1"
//    ViewModel and LiveData
    implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"

//    New Material Design
    implementation 'com.google.android.material:material:1.2.0-alpha03'

//    Kodein Dependency Injection
    implementation "org.kodein.di:kodein-di-generic-jvm:6.2.1"
    implementation "org.kodein.di:kodein-di-framework-android-x:6.2.1"

//    Android Room
    implementation "androidx.room:room-runtime:2.2.4"
    implementation "androidx.room:room-ktx:2.2.4"
    kapt "android.room:room-complier:2.2.4"
//    kapt 'androidx.room:room-compiler:2.1.0-alpha04'

//    Android Navigation Architecture
    implementation "androidx.navigation:navigation-fragment-ktx:2.2.0-rc04"
    implementation "androidx.navigation:navigation-ui-ktx:2.2.0-rc04"

}

这是我的项目级别build.gradle 文件:

buildscript {
    ext.kotlin_version = '1.3.61'
    repositories {
        google()
        jcenter()
        
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0-alpha02"
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {url 'https://jitpack.io'}


    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

【问题讨论】:

    标签: android kotlin mvvm


    【解决方案1】:

    androidx.room,不是android.room,也是room-compiler不是room-complier(不是i的位置):

    kapt "androidx.room:room-compiler:2.2.4"
    

    【讨论】:

    • 我已更改为“androidx”它仍然有同样的错误
    • 啊,是的,你也拼错了compiler。我更新了我的答案
    • 谢谢哥们。几天来找到解决方案。成功了!
    【解决方案2】:

    如果您的错误是: 如何解决此错误“找不到 android.room:room-complier:2.2.5” 您可以将Room 降级为2.2.4 并解决。

    【讨论】:

      【解决方案3】:

      在我的情况下,我收到此错误是因为 INVALID RAW 查询。

      请检查您的查询。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-02-11
        • 2018-05-30
        • 2019-12-18
        • 1970-01-01
        相关资源
        最近更新 更多