【发布时间】:2019-08-18 05:08:25
【问题描述】:
我正在使用 android 架构组件开发新应用程序,但我从 gradle 收到以下错误
注解处理器现在必须显式声明。发现编译类路径的以下依赖项包含注释处理器。请将它们添加到 annotationProcessor 配置中。 - 生命周期编译器 2.0.0.jar (androidx.lifecycle:lifecycle-compiler:2.0.0) 或者,设置 android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true 以继续以前的行为。请注意,此选项已弃用,将来将被删除。 请参阅https://developer.android.com/r/tools/annotation-processor-error-message.html
下面是我的 app.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.lifecycleawaredemo"
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.0.2'
implementation 'androidx.core:core-ktx:1.0.2'
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'
implementation 'androidx.lifecycle:lifecycle-compiler:2.0.0'
def lifecyle_version = "1.1.1"
implementation "android.arch.lifecycle:extensions:$lifecyle_version"
implementation "android.arch.lifecycle:compiler:$lifecyle_version"
}
在我的 build.gradle 下
buildscript {
ext.kotlin_version = '1.3.31'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
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
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'https://maven.google.com' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
【问题讨论】:
标签: android android-gradle-plugin android-room androidx