Suddenly when Syncing Gradle, I get this error:
WARNING: API 'variant.getJavaCompile()' is obsolete and has been
replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance
Affected Modules: app
I've got this build.gradle for the app module:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
buildToolsVersion "28.0.2"
defaultConfig {
applicationId "..."
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "..."
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
versionNameSuffix = version_suffix
[...]
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
[...]
}
debug {
[...]
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.61"
implementation 'androidx.appcompat:appcompat:1.0.0-rc02'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "com.android.support:preference-v7:28.0.0"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
implementation 'com.google.android.material:material:1.0.0-rc02'
[...]
}
I can compile the app correctly, but it's a bit bothering, and as I see it, something will stop working at the end of 2019. Any ideas of what is it and how to solve it?
I face this issue after updating to 3.3.0
If you are not doing what error states in gradle file, it is some plugin that still didn't update to the newer API that cause this. To figure out which plugin is it do the following (as explained in "Better debug info when using obsolete API" of 3.3.0 announcement):
Add 'android.debug.obsoleteApi=true' to your gradle.properties file which will log error with a more details
Try again and read log details. There will be a trace of "problematic" plugin
When you identify, try to disable it and see if issue is gone, just to be sure
go to github page of plugin and create issue which will contain detailed log and clear description, so you help developers fix it for everyone faster
be patient while they fix it, or you fix it and create PR for devs
Hope it helps others
This issue is fixed now with update Fabric Gradle version 1.30.0:
Update release: March 19, 2019
Please see this Link: https://docs.fabric.io/android/changelog.html#march-15-2019
Please update your classpath dependency in project level Gradle:
buildscript {
// ... repositories, etc. ...
dependencies {
// ...other dependencies ...
classpath 'io.fabric.tools:gradle:1.30.0'
}
}
In my case, it was caused from gms services 4.3.0. So i had to change it to:
com.google.gms:google-services:4.2.0
I have found this by running:
gradlew sync -Pandroid.debug.obsoleteApi=true
in terminal. Go to view -> tool windows -> Terminal in Android Studio.
This is just a warning and it will probably be fixed before 2019 with plugin updates so don't worry about it. I would recommend you to use compatible versions of your plugins and gradle.
You can check your plugin version and gradle version here for better experience and performance.
https://developer.android.com/studio/releases/gradle-plugin
Try using the stable versions for a smooth and warning/error free code.
I also faced the same issue. And after searching for a while, I figured it out that the warning was arising because of using the latest version of google-services plugin (version 4.3.0). I was using this plugin for Firebase functionalities in my application by the way.
All I did was to downgrade my google-services plugin in buildscript in the build.gradle(Project) level file as follows:
buildscript{
dependencies {
// From =>
classpath 'com.google.gms:google-services:4.3.0'
// To =>
classpath 'com.google.gms:google-services:4.2.0'
}
}
1) Add android.debug.obsoleteApi=true to your gradle.properties. It will show you which modules is affected by your the warning log.
2) Update these deprecated functions.
variant.javaCompile to variant.javaCompileProvider
variant.javaCompile.destinationDir to
variant.javaCompileProvider.get().destinationDir
Change your Google Services version from your build.gradle:
dependencies {
classpath 'com.google.gms:google-services:4.2.0'
}
This is a warning spit out by build tools for two reasons.
1. One of the plugin is relying on Task instead of TaskProvider, there is nothing much we can do.
2. You have configured usage of task, where as it supports TaskProvider.
WARNING: API 'variant.getGenerateBuildConfig()' is obsolete and has been replaced with 'variant.getGenerateBuildConfigProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance
WARNING: API 'variant.getMergeResources()' is obsolete and has been replaced with 'variant.getMergeResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance
Look out for snippets as below & update.
android {
<library|application>Variants.all { variant ->
/* Disable Generating Build config */
// variant.generateBuildConfig.enabled = true // <- Deprecated
variant.generateBuildConfigProvider.configure {
it.enabled = true // Replacement
}
}
}
Similarly, find usages of 'variant.getJavaCompile()' or 'variant.javaCompile', 'variant.getMergeResources()' or 'variant.mergeResources'. Replace as above.
More information at Task Configuration Avoidance
Downgrading the version of Gradle worked for me:
classpath 'com.android.tools.build:gradle:3.2.0'
Upgrading the Kotlin (Plugin and stdLib) version to 1.3.1 solved that warning in my case. Update the Kotlin version in whole project by replacing existing Kotlin version with :
ext.kotlin_version = '1.3.50'
Go back from classpath 'com.android.tools.build:gradle:3.3.0-alpha13' to classpath 'com.android.tools.build:gradle:3.2.0'
this worked for me
Updating gradle to gradle:3.3.0
The default 'assemble' task only applies to normal variants. Add test variants as well.
android.testVariants.all { variant ->
tasks.getByName('assemble').dependsOn variant.getAssembleProvider()
}
also comment apply fabric
//apply plugin: 'io.fabric'
Update fabric plugin to the latest in project level Gradle file (not app level). In my case, this line solved the problem
classpath 'io.fabric.tools:gradle:1.25.4'
to
classpath 'io.fabric.tools:gradle:1.29.0'
In my case
build.gradle(Project)
was
ext.kotlin_version = '1.2.71'
updated to
ext.kotlin_version = '1.3.0'
looks problem has gone for now
In my case, I had to comment out com.google.firebase.firebase-crash plugin:
apply plugin: 'com.android.application'
// apply plugin: 'com.google.firebase.firebase-crash' <== this plugin causes the error
It is a bug since Android Studio 3.3.0
When the plugin detects that you're using an API that's no longer supported, it can now provide more-detailed information to help you determine where that API is being used. To see the additional info, you need to include the following in your project's gradle.properties file:
android.debug.obsoleteApi=true
if I remove this row from application gradle:
apply plugin: 'io.fabric'
error will not appear anymore.
Reference link github
Migrate your project to androidX.
dependencies are upgraded to androidX. so if you want to use androidX contents migrate your project to androidX.
With Android Studio 3.2 and higher, you can quickly migrate an existing project to use AndroidX by selecting Refactor > Migrate to AndroidX from the menu bar.
Downgrading dependencies may fix your problem this time - but not recommended
This fixed my problem.. All I needed to do was to downgrade my google-services plugin in buildscript in the build.gradle(Project) level file as follows
buildscript{
dependencies {
// From =>
classpath 'com.google.gms:google-services:4.3.0'
// To =>
classpath 'com.google.gms:google-services:4.2.0'
// Add dependency
classpath 'io.fabric.tools:gradle:1.28.1'
}
}
Here a temporary workaround, If you are using room just upgrade to 1.1.0 or higher
implementation "android.arch.persistence.room:runtime:1.1.0"
it removes this warning for me.
keep you Project(not app) Build.gradle dependncies classpath version code is new
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0-beta01'
classpath 'com.novoda:bintray-release:0.8.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
This is a popular question. If you do not use these methods, the solution is updating the libraries.
Please update your kotlin version, and all your dependencies like fabric, protobuf etc. If you are sure that you have updated everything, try asking the author of the library.
Upgrading protobuf-gradle-plugin to version 0.8.10 solved my problem. Replace your existing protobuf with
classpath 'gradle.plugin.com.google.protobuf:protobuf-gradle-plugin:0.8.10'
That's mostly due to libraries which are obsolete. To check for new updates manually, you should navigate to
Analyze > "Run Inspection By Name"
That should be enough. Another option is to run a gradle dependency update using
./gradlew dependencyUpdates
that will produce a report like this:
:dependencyUpdates
------------------------------------------------------------
: Project Dependency Updates (report to plain text file)
------------------------------------------------------------
The following dependencies are using the latest milestone version:
- com.github.ben-manes:gradle-versions-plugin:0.15.0
The following dependencies have later milestone versions:
- com.google.auto.value:auto-value [1.4 -> 1.4.1]
- com.google.errorprone:error_prone_core [2.0.19 -> 2.0.21]
- com.google.guava:guava [21.0 -> 23.0-rc1]
- net.ltgt.gradle:gradle-apt-plugin [0.9 -> 0.10]
- net.ltgt.gradle:gradle-errorprone-plugin [0.0.10 -> 0.0.11]
...
upgrading the google services in project-level build.gradle solved my problem.
After upgrading:
dependencies {
...
classpath 'com.google.gms:google-services:4.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
I had same problem and it solved by defining kotlin gradle plugin version in build.gradle file.
change this
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
to
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50{or latest version}"
In my case I followed this.
Summary, in gradle app level: change this :
variant.outputs.all { output ->
variant.assemble.doLast {
....
}
}
to
variant.outputs.all { output ->
variant.getAssembleProvider().configure() {
it.doLast {
....
}
}
I have an Android studio project in which I have added a Java library module, which I call core. My three Gradle build files look like this.
project/build.gradle
buildscript {
ext.kotlin_version = '1.2.40'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
core/build.gradle
apply plugin: 'java-library'
apply plugin: 'kotlin'
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7"
...
}
app/build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android { ... }
dependencies {
implementation project(':core')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
testImplementation 'junit:junit:4.12'
}
The problem I have is that, in core/build.gradle, the kotlin-stdlib-jdk7 line is giving me the warning Plugin version (1.2.40) is not the same as library version (jdk7-1.2.40). I have tried changing it to:
implementation "org.jetbrains.kotlin:kotlin-stdlib"
implementation "org.jetbrains.kotlin:kotlin-stdlib:1.2.40"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.2.40"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
But the warning is still there. The build still runs successfully, and I know I can surpress the warning without any problems and ignore it, but I really want to know why this is happening and how I can get rid of it. I am using Android Studio 3.0.1. Does anyone know of a solution to this?
Starting from Kotlin 1.4 dependency on the standard library added by default:
You no longer need to declare a dependency on the stdlib library in any Kotlin Gradle project, including a multiplatform one. The dependency is added by default.
The automatically added standard library will be the same version of the Kotlin Gradle plugin, since they have the same versioning.
For platform-specific source sets, the corresponding platform-specific variant of the library is used, while a common standard library is added to the rest. The Kotlin Gradle plugin will select the appropriate JVM standard library depending on the kotlinOptions.jvmTarget compiler option of your Gradle build script.
Link to Kotlin Gradle plugin documentation.
This is a bug in the Kotlin plugin. I've filed an issue in the Kotlin issue tracker. You can simply ignore the message.
EDIT: JetBrains marked the issue as a duplicate of KT-23744 "Kotlin library and Gradle plugin versions are different" inspection false positive for non-JVM dependencies".
Solution, in my case, I got rid of the line
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
in the app level Gradle and the warning disappear
As the Kotlin page says :
" You no longer need to declare a dependency on the stdlib library in any Kotlin Gradle project, including a multiplatform one. The dependency is added by default.
The automatically added standard library will be the same version of the Kotlin Gradle plugin, since they have the same versioning.
For platform-specific source sets, the corresponding platform-specific variant of the library is used, while a common standard library is added to the rest. The Kotlin Gradle plugin will select the appropriate JVM standard library depending on the kotlinOptions.jvmTarget compiler option of your Gradle build script."
You might be facing this after upgrading kotlin version, Actually, older versions are still in your caches, In this case, you need to do the following steps
Invalidate cache
Clean project
Sync project with gradle files
Now your warning will be gone.
[build.gradle(Module)]
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.5.10'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.10'
...
}
My project automatically added
(implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.10')
to the project build file. After moving the implementation to the module file, and removing
(implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.10')
the warning went away.
The 'stdlib' needs to match the 'stdlib-jdk' in the module file.
I faced the same issue while using Firebase with Kotlin.
I had to upgrade all the dependencies with their latest version available.
Note: have your kotlin-reflect and kotlin-stdlib versions same.
after many days i have solve the issue
Update the kotlin_version to '1.4.32'
In my case, I set the version number for all modules the same as gradle of app as latest version, and problem resolved.
I get the following errors when trying to execute my project:
Error: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.
- butterknife-7.0.1.jar (com.jakewharton:butterknife:7.0.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. See
https://developer.android.com/r/tools/annotation-processor-error-message.html
for more details.
Please don't mark this question as duplicate as other question regrading this, here, is for lombok, which I'm not using.
As the error says, you need to use annotationProcessor in your app build.gradle. Afaik, you need to upgrade the ButterKnife library to version 8.8.1. You need to use something like this:
dependencies {
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
Please check Android studio 3.0 butterknife error issue for the details.
Going through the following process makes my problem solved.
In the build.gradle(module app)
apply the plugin:
apply plugin: 'com.jakewharton.butterknife'
Add the following lines in the dependencies section:
annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
implementation 'com.jakewharton:butterknife:8.7.0'
In the build.gradle(Project:projectName), add the classPath in the dependencies like this :
classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'
It will fix this issue.
In case if not then add maven:
maven {
url 'https://maven.google.com'
}
Adding these two line in app/build.gradle
dependencies {
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
}
It worked for me
After upgrading from 2.2 to 2.3 I see this warning
and when I try to compile the project I see this compilation error
How can i solve this issue without downgrading to a previous gradle version?
Is there any update of android-apt that can solve this issue?
The android-apt plugin has been deprecated.
Check here for the migration guide:
As of the Android Gradle plugin version 2.2, all functionality that was previously provided by android-apt is now available in the Android plugin.
You can remove android-apt by following the migration guide to get the equivalent functionalities.
The important parts from the migration guide:
Make sure you are on the Android Gradle 2.2 plugin or newer.
Remove the android-apt plugin from your build scripts
Change all apt, androidTestApt and testApt dependencies to their new format:
dependencies {
compile 'com.google.dagger:dagger:2.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.0'
}
Also in the Android Gradle plugin there is an explicit check for this, which is what you are seeing:
using incompatible plugins for the annotation processing android-apt
Future Android Gradle plugin versions will not be compatible with the way android-apt works, which is the reason for that check.
For me, I was having this error while using Contentful's Vault library which specifies that you include:
apply plugin: 'com.neenbedankt.android-apt'
and
compile 'com.contentful.vault:core:2.1.0'
apt 'com.contentful.vault:compiler:2.1.0'
What you need to do is DELETE apply plugin: 'com.neenbedankt.android-apt'
and then CHANGE:
compile 'com.contentful.vault:core:2.1.0'
apt 'com.contentful.vault:compiler:2.1.0'
to
annotationProcessor 'com.contentful.vault:compiler:2.1.0'
annotationProcessor 'com.contentful.vault:core:3.0.1'
You can always check https://github.com/contentful/vault for the latest versions
Remove apt plugin
Change:
apt -> compile
testApt -> testAnnotationProcessor
androidTestApt -> androidTestAnnotationProcessor
In your build.gradle (app), add to defaultConfig:
vectorDrawables.useSupportLibrary = true
Piggybacking on #Gabriele Mariotti here since his answer is pretty spot on and implies this but doesn't state it. Gradle also does not suggest this as a valid option though it is as well. The testing equivalent for androidTestApt and testApt is androidTestAnnotationProcessor and testAnnotationProcessor.
Example:
testApt "com.google.dagger:dagger-compiler:$daggerVersion"
androidTestApt "com.google.dagger:dagger-compiler:$daggerVersion"
Should be changed to
testAnnotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion"
androidTestAnnotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion"
In case the annotation processor has arguments, one also might have to change this:
apt {
arguments {
KEY "VALUE"
}
}
to this:
android {
...
defaultConfig {
...
javaCompileOptions {
annotationProcessorOptions {
arguments = ['KEY': 'VALUE']
}
}
}
}
After update Android Studio to 2.3 version I have warning:
Warning:Using incompatible plugins for the annotation processing:
android-apt. This may result in an unexpected behavior.
Any solutions? My app stopped working...
Your app level gradle dependencies should include (as per butterknife website instructions):
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
You can remove the line :
apply plugin: 'com.neenbedankt.android-apt'
Annotation Processing became available in Android Gradle plugin (2.2 and later) so there is now no need to use the above plugin anymore if using this version of gradle or greater.
If you'd like to know how to turn annotation processing off and on and AS the setting is in :
Settings > Build, Execution, Deployment > Compiler > Annotation Processors
In my project I use, among other things, Butter Knife and Immutables. After adding Immutables I got the following warning
Warning:Using incompatible plugins for the annotation processing:
android-apt. This may result in an unexpected behavior.
and ButterKnife stopped working.
My configuration was as follows:
build.gradle (Project: MyApplication)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
build.gradle (Module: app)
apply plugin: 'com.android.application'
apply plugin: 'android-apt'
...
dependencies {
...
// Butter Knife
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
// Immutables
apt 'org.immutables:value:2.4.4'
provided 'org.immutables:value:2.4.4'
provided 'org.immutables:builder:2.4.4'
provided 'org.immutables:gson:2.4.4'
}
After changing
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
to
apt 'com.jakewharton:butterknife-compiler:8.5.1'
warning disappeared and everything works as it should.
UPDATE
As Mark said, an annotation processor was included in the Gradle version 2.2 , so there is no reason to provide an extra one.
So:
1) Remove the class path for the apt from the build.gradle (Project: MyApplication)
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
2) Remove the plug in from the build.gradle (Module: app)
apply plugin: 'android-apt'
3) Change the dependencies from apt to the new annotationProcessor
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
annotationProcessor 'org.immutables:value:2.4.4'
To add to #Milan's answer, if you used the hotchemi permissiondispatcher library in your app level gradle file then you should replace it as follows:
Replace
apt 'com.github.hotchemi:permissionsdispatcher-processor:2.4.0'
with
annotationProcessor 'com.github.hotchemi:permissionsdispatcher-processor:2.4.0'
At Project Gradle buildscript --> dependencies block, remove the second classpath line :
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
And at app Gradle dependencies block, change these lines, use api and annotationProcessor :
api 'com.google.dagger:dagger:2.19'
annotationProcessor 'com.google.dagger:dagger-compiler:2.19'
Also, remove this one:
//apply plugin: 'com.neenbedankt.android-apt'