Kotlin 编译器在对 build.gradle 文件进行更改后抛出注释错误
Kotlin compiler throwing annotation errors after changes made to the build.gradle file
我对 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.kt
和 EntryDatabase.kt
文件的以下错误:
错误信息很清楚。
房间的删除、更新方法签名已更改。它需要 return void 或 int。
编辑:我再次检查,您的 gradle 文件混合了 androidx 库和 pre-AndroidX 版本的 Lifecycle。
请按照 link 使用正确的库组合:https://developer.android.com/jetpack/androidx/releases/lifecycle
我对 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.kt
和 EntryDatabase.kt
文件的以下错误:
错误信息很清楚。 房间的删除、更新方法签名已更改。它需要 return void 或 int。
编辑:我再次检查,您的 gradle 文件混合了 androidx 库和 pre-AndroidX 版本的 Lifecycle。
请按照 link 使用正确的库组合:https://developer.android.com/jetpack/androidx/releases/lifecycle