我正在尝试将以下库添加到我的应用
中 ext {
roomLibraryVersion = '1.1.0'
lifeCycleVersion = '1.1.1'
}
//room data base
implementation "android.arch.persistence.room:runtime:$roomLibraryVersion"
implementation "android.arch.persistence.room:compiler:$roomLibraryVersion"
annotationProcessor "android.arch.persistence.room:compiler:$roomLibraryVersion"
//life cycle
implementation "android.arch.lifecycle:runtime:$lifeCycleVersion"
implementation "android.arch.lifecycle:compiler:$lifeCycleVersion"
implementation "android.arch.lifecycle:extensions:$lifeCycleVersion"
// rx android
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
implementation "io.reactivex.rxjava2:rxjava:2.1.14"
implementation 'android.arch.persistence.room:rxjava2:1.1.0'
//paging
implementation 'android.arch.paging:runtime:1.0.0'
我在运行代码时遇到异常。任何人都可以帮我解决这个问题
Execution failed for task ':app:javaPreCompileDebug'.
> Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration.
- compiler-1.1.1.jar (android.arch.lifecycle:compiler:1.1.1)
Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future.
答案 0 :(得分:2)
更改:
implementation "android.arch.lifecycle:compiler:$lifeCycleVersion"
到:
annotationProcessor "android.arch.lifecycle:compiler:$lifeCycleVersion"
答案 1 :(得分:0)
如果您使用的是Kotlin,请将“实现”替换为“ kapt”
implementation "android.arch.lifecycle:extensions:$lifecycle_version"
kapt "android.arch.lifecycle:compiler:$lifecycle_version"
并将其放在应用程序级别Gradle文件的顶部
apply plugin: 'kotlin-kapt'