首页 > 其他分享> > 错误:找不到注释处理器’__gen.AnnotationProcessorWrapper_debug_android_databinding_annotationprocessor_ProcessDa
错误:找不到注释处理器’__gen.AnnotationProcessorWrapper_debug_android_databinding_annotationprocessor_ProcessDa
作者:互联网
因此,我正在尝试使用Kotlin构建我的Android项目并向其中添加Android DataBinding库.在Android Studio 2.2.3中,它没有问题.但是在更新到最新的Android Studio版本(2.3.0)之后,尝试运行该应用程序时出现此错误.
这是我的项目的build.gradle
buildscript {
ext.kotlinVersion = '1.1.0'
ext.androidGradlePluginVersion = '2.3.0'
...
dependencies {
classpath "com.android.tools.build:gradle:${androidGradlePluginVersion}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
...
这是我的应用程序的build.gradle
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
...
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
dataBinding.enabled = true
}
dependencies {
...
compile "com.google.dagger:dagger:${daggerVersion}"
compile "com.google.dagger:dagger-compiler:${daggerVersion}"
provided 'javax.annotation:jsr250-api:1.0'
kapt "com.android.databinding:compiler:$androidGradlePluginVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
}
为了使Kotlin与Android DataBinding库一起使用,我需要更新一些东西吗?请帮忙.提前致谢.
编辑:
基于@Rene答案,我试图用kotlin-kapt替换kotlin-android-extensions,但是当我尝试同步gradle时,我遇到了另一个错误.
有人从这个错误出了什么问题吗?谢谢
解决该问题的方法:
事实证明,我只需要更新gradle中与Dagger2相关的某些行即可.我从我的项目的build.gradle文件中删除了以下这一行.
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
并在我的应用程序的build.gradle文件中更新与Dagger2相关的依赖项,如下所示.
compile "com.google.dagger:dagger:${daggerVersion}"
kapt "com.google.dagger:dagger-compiler:${daggerVersion}"
provided 'org.glassfish:javax.annotation:10.0-b28'
我从此article获得了此设置
这是我为我工作的build.gradle内容.
项目的build.gradle
buildscript {
ext.kotlinVersion = '1.1.0'
ext.androidGradlePluginVersion = '2.3.0'
repositories {
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:${androidGradlePluginVersion}"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
应用程序的build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
dexOptions {
maxProcessCount 2
javaMaxHeapSize "2g"
}
defaultConfig {
applicationId "my.application.id"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/rxjava.properties'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
dataBinding.enabled = true
}
kapt {
generateStubs = true
}
ext {
supportLibVersion = '25.2.0'
retrofitVersion = '2.2.0'
daggerVersion = '2.7'
googleServiceVersion = '10.2.0'
rxJavaVersion = '2.0.6'
rxAndroidVersion = '2.0.1'
glideVersion = '3.7.0'
constraintLayoutVersion = '1.0.1'
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
compile "com.squareup.retrofit2:retrofit:${retrofitVersion}"
compile "com.squareup.retrofit2:converter-gson:${retrofitVersion}"
compile "com.squareup.retrofit2:adapter-rxjava:${retrofitVersion}"
compile 'com.squareup.okhttp3:logging-interceptor:3.3.0'
compile "com.android.support:support-compat:${supportLibVersion}"
compile "com.android.support:support-core-utils:${supportLibVersion}"
compile "com.android.support:support-core-ui:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
compile "com.android.support:appcompat-v7:${supportLibVersion}"
compile "com.android.support:recyclerview-v7:${supportLibVersion}"
compile "com.android.support:cardview-v7:${supportLibVersion}"
compile "com.android.support.constraint:constraint-layout:${constraintLayoutVersion}"
compile "com.google.dagger:dagger:${daggerVersion}"
kapt "com.google.dagger:dagger-compiler:${daggerVersion}"
provided 'org.glassfish:javax.annotation:10.0-b28'
compile 'com.android.support:multidex:1.0.1'
compile('com.mikepenz:fastadapter:1.8.2@aar') {
transitive = true
}
compile 'com.mikepenz:fastadapter-extensions:1.8.0@aar'
compile 'com.mikepenz:materialize:1.0.0@aar'
compile "com.google.android.gms:play-services-location:${googleServiceVersion}"
compile "com.google.android.gms:play-services-maps:${googleServiceVersion}"
compile "io.reactivex.rxjava2:rxjava:${rxJavaVersion}"
compile "io.reactivex.rxjava2:rxandroid:${rxAndroidVersion}"
compile "com.github.bumptech.glide:glide:${glideVersion}"
kapt "com.android.databinding:compiler:$androidGradlePluginVersion"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlinVersion"
compile 'de.hdodenhof:circleimageview:2.1.0'
}
repositories {
mavenCentral()
}
谢谢.
解决方法:
从Kotlin 1.1开始,我不得不切换到更新的Kotlin注释处理器.
像这样应用它:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
我发现它在kotlin-1-0-6-is-here的1.0.6版本中首次提到
标签:android-studio,dagger-2,kotlin,android-databinding,android 来源: https://codeday.me/bug/20191026/1934583.html