Based on ButterKnife lib, I upgrade to new version 8.5.1. I used
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
But it warns me in my Android Studio 2.3. And ButterKnife doesn't work(cannot bind view).
Warning:Using incompatible plugins for the annotation processing:
android-apt. This may result in an unexpected behavior.
I change annotationProcessor to apt (I had plugin apply plugin: 'com.neenbedankt.android-apt' in my gradle) and it works as old version without warning (I used apt for old version 8.4.0)
compile 'com.jakewharton:butterknife:8.5.1'
apt 'com.jakewharton:butterknife-compiler:8.5.1'
I think Android Studio 2.3 is incomatible with Annottaion processing. I searched and found to enable Annotation Processors in Android Studio 2.2 but cannot find in Android Studio 2.3
Settings > Build, Execution, Deployment > Compiler > Annotation
Processors
Anyone can explain this problem? Thanks!
kindly
//apply plugin: 'com.neenbedankt.android-apt' <--remove this
apply plugin: 'com.jakewharton.butterknife' <-- add this
dependencies {
//classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8' <-- remove this
classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1' <-- add this
}
then in app dependencies
//Butterknife
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
Simple and easy. Just add these lines to your build.gradle
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
An annotation processor was included in the Gradle version 2.2, so there is no reason to provide an extra one.
Check my updated answer here.
Related
I was using Butterknife in my project and after updating Android Studio and Gradle plugin to version 3.1.2, I can not continue using Butterknife.
Has anyone faced this problem and resolved it?
I have considered eliminating Butterknife and using Android Data Binding, is it a good option?
Just Add this dependency in your app.gradle file .its work fine with Android studio 3.1.2 .may be you have some other problem with gradle.
New Approach
In app.gradle
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
In project.gradle
classpath 'com.android.tools.build:gradle:3.1.2'
If you use these plugin in app.gradle then Remove these lines.
Old Approach
apply plugin: 'com.android.library'
apply plugin: 'com.jakewharton.butterknife'
project.gradle
classpath 'com.jakewharton:butterknife-gradle-plugin:8.8.1'
I think,there is some other problem please use this dependency.
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
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'
Two warnings show up when I try to build my project:
Warning:Using incompatible plugins for the annotation processing: android-apt. This may result in an unexpected behavior.
and also at the end of all the binding errors:
Warning:The following options were not recognized by any processor: '[android.databinding.artifactType, android.databinding.printEncodedErrors, android.databinding.minApi, android.databinding.isTestVariant, android.databinding.enableDebugLogs, android.databinding.sdkDir, android.databinding.bindingBuildFolder, android.databinding.enableForTests, android.databinding.modulePackage, android.databinding.generationalFileOutDir, android.databinding.xmlOutDir]'
I tried to enable annotation processors and removed all apt reference and changed this:
apt 'com.jakewharton:butterknife-compiler:8.2.1'
to this:
annotationProcessor 'com.jakewharton:butterknife-compiler:8.2.1'
but it didn't work.
Just replace apt with annotationProcessor in your build.gradle file.
And remove apt plugins wherever you see them.
You can down version of tools build gradle from 2.3.0 to 2.2.3 to avoid warning like that
classpath 'com.android.tools.build:gradle:2.2.3'
Android apt is no longer supported in Android studio 2.3
see https://bitbucket.org/hvisser/android-apt/issues/73/no-longer-compatible-with-gradle-at-v230
after i update. i also have this kind of situation. Remove any apt like "com.neenbedankt.gradle.plugins:android-apt:1.8" from your dependencies classpath
but before that.. please invalidate cache/restart AS and clean gradle.
then
dependencies {
classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
}
then
apply plugin: 'com.jakewharton.butterknife'
then
compile "com.jakewharton:butterknife:8.5.1",
annotationProcessor "com.jakewharton:butterknife-compiler:8.5.1"
the lastly..put this in last app module
configurations.all {
resolutionStrategy {
force "com.android.support:support-annotations:25.2.0"
}
}