I get the following error after I try to build my project:
Error:android-apt plugin is incompatible with the Android Gradle plugin. Please use 'annotationProcessor' configuration instead.
I tried to add annotationProcessor '.....'
after every implementation
but no success to get rid of the error.
This happens after upgrading android studio to the latest version ( 3.0 ).
Edit:
Adding includeCompileClasspath true
inside defaultConfig
doesn't help:
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}
Any solutions?
First of all, after upgrading there are a few changes to gradle.
Its important to upgrade to the latest gradle version to fix that.
That means that you need to add the proper version for your build gradle which is currently
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
the next step is to remove your android-apt
which is not longer needed.
its enough to have only apply plugin: 'com.android.application'
Onec you have done that, change your dependencies from
compile
to implementation
, apt
to annotationProcessor
and testCompile
to androidTestImplementation
If you have done that invalidate your cache and restart which is very important.
Then it should work.
You can find a working gradle file using the latest version at
app build.gradle and project build.gradle
p/s : For many people still use Realm old version,
Please update to latest version since old version still use "android-apt".
you have to add annotationProcessorOptions
in app level gradle.
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.your.packagename"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
// add below section
javaCompileOptions {
annotationProcessorOptions {
includeCompileClasspath true
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With