【问题标题】:Kotlin compiler throwing annotation errors after changes made to the build.gradle fileKotlin 编译器在对 build.gradle 文件进行更改后抛出注释错误
【发布时间】:2019-05-31 10:10:12
【问题描述】:

我对我的build.gradle(app) 文件进行了以下更改。

apply plugin: 'kotlin-kapt'

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.core:core-ktx:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.recyclerview:recyclerview:1.1.0-alpha05'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'com.google.android.material:material:1.1.0-alpha07'

    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0-alpha01'
    kapt 'androidx.lifecycle:lifecycle-compiler:2.0.0-rc01'

    implementation 'androidx.room:room-runtime:2.1.0-rc01'
    kapt  'androidx.room:room-compiler:2.0.0-rc01'

    implementation 'androidx.paging:paging-runtime:2.1.0'

    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'

    implementation 'io.sentry:sentry-android:1.7.16'
    implementation 'org.slf4j:slf4j-nop:1.7.25'
}

现在 Kotlin 编译器对我的 EntryDAO.ktEntryDatabase.kt 文件抛出以下错误:

【问题讨论】:

    标签: android gradle mvvm kotlin androidx


    【解决方案1】:

    错误信息很清楚。 房间的删除、更新方法签名已更改。它需要返回 void 或 int。

    编辑:我再次检查,您的 gradle 文件混合了 androidx 库和生命周期的预 AndroidX 版本。

    请点击链接使用正确的库组合:https://developer.android.com/jetpack/androidx/releases/lifecycle

    【讨论】:

    • 但他们没有。我没有对他们的代码进行任何物理更改。
    • 问题依然存在。我将所有内容迁移到 androidx(检查编辑)
    猜你喜欢
    • 2016-11-27
    • 2021-07-23
    • 1970-01-01
    • 2012-07-08
    • 1970-01-01
    • 1970-01-01
    • 2011-05-29
    • 2015-09-02
    • 2016-02-09
    相关资源
    最近更新 更多