我在现有的Android项目中使用了一些kotlin类(已经具有领域),kotlin类未使用任何领域功能,现在在运行时出现此错误
:app:compileDebugKotlin
Using kotlin incremental compilation
:app:compileDebugJavaWithJavac
Destination for generated sources was modified by kapt. Previous value = /home/debu/AndroidStudioProjects/WT_Application/app/build/generated/source/apt/debug
error: Annotation processor '__gen.AnnotationProcessorWrapper_debug_io_realm_processor_RealmProcessor' not found
1 error
:app:compileDebugJavaWithJavac FAILED
:app:copyDebugKotlinClasses SKIPPED
FAILURE: Build failed with an exception.
我的应用程序的build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'realm-android'
android {
def globalConfiguration = rootProject.extensions.getByName("ext")
compileSdkVersion globalConfiguration.getAt("androidCompileSdkVersion")
buildToolsVersion globalConfiguration.getAt("androidBuildToolsVersion")
defaultConfig {
applicationId globalConfiguration.getAt("androidApplicationId")
minSdkVersion globalConfiguration.getAt("androidMinSdkVersion")
targetSdkVersion globalConfiguration.getAt("androidTargetSdkVersion")
versionCode globalConfiguration.getAt("androidVersionCode")
versionName globalConfiguration.getAt("androidVersionName")
testInstrumentationRunner globalConfiguration.getAt("testInstrumentationRunner")
/*jackOptions {
enabled true
}*/
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
dataBinding {
enabled = true
}
}
dependencies {
def presentationDependencies = rootProject.ext.presentationDependencies
def presentationTestDependencies = rootProject.ext.presentationTestDependencies
def developmentDependencies = rootProject.ext.developmentDependencies
compile presentationDependencies.dagger
compile presentationDependencies.butterKnife
compile presentationDependencies.recyclerView
compile presentationDependencies.cardview
compile presentationDependencies.rxJava
compile presentationDependencies.rxAndroid
compile presentationDependencies.appcompat
compile presentationDependencies.constraintLayout
compile presentationDependencies.design
compile presentationDependencies.retrofit
compile presentationDependencies.gsonconverter
compile presentationDependencies.rxjavaadapter
compile presentationDependencies.glide
compile presentationDependencies.flexbox
compile presentationDependencies.maps
compile presentationDependencies.mapUtils
compile presentationDependencies.pagerIndicator
annotationProcessor presentationDependencies.daggerCompiler
annotationProcessor presentationDependencies.butterKnifeCompiler
provided presentationDependencies.javaxAnnotation
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
androidTestCompile presentationTestDependencies.junit
androidTestCompile presentationTestDependencies.mockito
androidTestCompile presentationTestDependencies.dexmaker
androidTestCompile presentationTestDependencies.dexmakerMockito
androidTestCompile presentationTestDependencies.espresso
androidTestCompile presentationTestDependencies.testingSupportLib
//Development
compile developmentDependencies.leakCanary
compile files('libs/YouTubeAndroidPlayerApi.jar')
}
repositories {
mavenCentral()
}
项目build.gradle
apply from: 'buildsystem/dependencies.gradle'
buildscript {
ext.kotlin_version = '1.1.2-4'
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.2'
classpath "io.realm:realm-gradle-plugin:3.2.0"
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 {
ext {
androidApplicationId = 'com.wandertrails'
androidVersionCode = 1
androidVersionName = "1.0"
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
testApplicationId = 'com.wandertrails.test'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
现在有人可以找出这个错误的原因吗?
解决方法:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'
和
kapt presentationDependencies.daggerCompiler
kapt presentationDependencies.butterKnifeCompiler
可能会修复它.