-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Description
Android studio version: Android studio 3.0 preview
gradle plugin:
classpath 'com.android.tools.build:gradle:3.0.0-alpha1'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.6.0'
expection:
Error:Unable to find method 'com.android.build.gradle.api.BaseVariant.getOutputs()Ljava/util/List;'.
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
<a href="syncProject">Re-download dependencies and sync project (requires network)</a></li><li>The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
<a href="stopGradleDaemons">Stop Gradle build processes (requires restart)</a></li><li>Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.</li></ul>In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I commented out the plugin(classpath 'com.jakewharton:butterknife-gradle-plugin:8.6.0'), then sync through
ThePromoter, broglep, smanikandan14, mozarty, preraktrivedi and 71 morebayshier, MudassirAsghar22, ahmadameen222 and FEJonesYangsandsboy, YusukeHosonuma, ahmadameen222 and FEJonesYangmozarty, radityagumay, MattWilliams89, DagobertDokate, iman2420 and 12 more
Metadata
Metadata
Assignees
Labels
No labels
Projects
Milestone
Relationships
Development
Select code repository
Activity
zdongcoding commentedon May 19, 2017
not suppert
simplysoft commentedon May 20, 2017
We face the same problem,
this is probably related to https://developer.android.com/studio/preview/features/new-android-plugin-migration.html#variant_apimtdhllf commentedon May 21, 2017
Error:FAILURE: Build failed with an exception.
Execution failed for task ':app:javaPreCompileDebug'.
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
JakeWharton commentedon May 21, 2017
JvmName commentedon May 22, 2017
I'm using the following, with the following error:
root
build.gradle
:lib/build.gradle
:Stacktrace from
gradlew
:It looks like
ButterKnifePlugin.kt #27
is the offending line - it callsvariant.outputs.forEach
, but the new Android Gradle 3.0 plugin requiresvariants.outputs.all
(source)I'm not really a Gradle expert - is that really the extent of the change that's necessary?
JvmName commentedon May 22, 2017
I've also tried the 8.6.1-SNAPSHOT - same issue
preraktrivedi commentedon May 24, 2017
Did anyone find a workaround to this yet?
Paget96 commentedon May 27, 2017
Add
maven {
url 'https://maven.google.com'
}
Then you'll got an update for alpha2.
LucasFoulonMongai commentedon May 30, 2017
I have found a workaround :
Using the 8.4.0 version ( classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0' )
But it doesn't resolve the compatibility issue with "Feature Module" :
Error:Butterknife plugin can only be applied to android projects
SebasDesimone commentedon Jun 9, 2017
I understand the project can not depend on an unstable version of the gradle plugin (per comment on #964).
So, as far as I see, we could:
Any other option?
denizmveli commentedon Jun 16, 2017
Moving the butterknife plugin locally into our projects
buildSrc
is working for me as a workaroundiamBedant commentedon Jun 20, 2017
@denizmveli I tried your workaround, In my case, it did not work for "Feature Module"
37 remaining items
palkartimes commentedon Nov 23, 2017
@Aks-4125 It worked. Thanks
songhaonangit commentedon Dec 6, 2017
compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
It worked.Thanks
Times125 commentedon Dec 13, 2017
you can use gradle 2.3.3.My project can't work if I use gradle 3.0.0.But it works when I use gradle 2.3.3.
ZQiang94 commentedon Dec 26, 2017
@AndSync @SaudM remove apply plugin: 'com.jakewharton.butterknife' may be worked,but there will be NullPointerException. eg.

configurer commentedon Jan 3, 2018
yes i'm using Android studio 3.1 Canary 6. It can't find the butter knife jar though gradle.
redbar0n commentedon Feb 19, 2018
Some additional info from our post-mortem after solving this bug, in case it may contain useful info to help someone else solve it as well:
Problem encountered when upgrading from Android Studio 2.3.2 to Android Studio 3.0.1:
TL;DR:
Don't upgrade to Android Studio 3.0, unless also add this to your
app/build.gradle
file:Alternatively, you could instead upgrade the ButterKnife library, but for us that entailed a lot of refactor renaming, and an unknown amount of extra upgrade work, so it was not desirable at this time.
Problem:
Line 577 in our TimeLineUI.java gives a NullPointerException, because:
Line 101 in our TimeLineUI.java uses
@InjectView
to instantiatedashboardBackground
, but it is suddenly null at the time it is called.NB: We didn't make any changes to the codebase. Only the automatic changes Android Studio made to the
build.gradle
when building in the new Android Studio version.The stacktrace for the NullPointerException we got, similar to @ZQiang94 :
Cause and explanation:
The
@InjectView
annotations in the source code is used by the ButterKnife library to instantiate objects.If the instantiation isn't done properly then the app crashes on startup, on line 577.
ButterKnife used to instantiate these properly in Android Studio 2.3.2 (where the build would succeed).
We installed Android Studio 3.0 first, and tried to build. It made some changes to
build.gradle
:build.gradle (Project: projectname)
build script dependencies was upgraded:Android Studio 3.0 needs annotation processors specifically defined, for annotations to work correctly:
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html?utm_source=android-studio#annotationProcessor_config
If we try to fix it by simply adding this dependency in the
app/build.gradle
, to match the butterknife version we use:annotationProcessor 'com.jakewharton:butterknife-compiler:5.5.1'
Then we run into the issue that butterknife-compiler 5.5.1 JAR file doesn't exist (probably the same problem @configurer encountered), because ButterKnife didn't include butterknife-compiler until ButterKnife version 8.2.0.
We could upgrade to ButterKnife 8.2.0 or later.
But ButterKnife uses @BindView in the latest version, instead of
@InjectView
. So if we upgrade ButterKnife to 8.2.0 or later, then we have to rename all the instances of@InjectView
to@BindView
in 100+ places in 17+ files, and potentially have to make other changes too. The rename refactoring was attempted, but the upgrade entails we have to change other things in the codebase too. We are uncertain of the is uncertain of the size of the scope, and deems that it could take a while. So it is not worth it, at this time.So the initial conclusion is that we:
Postpone upgrading to Android Studio 3.0 and/or upgrading the ButterKnife library indefinitely, until we absolutely need to do it. If so, use the suggestion by songhaonangit: Android studio 3.0 butterknife error #963 (comment)
Quick fix: Downloaded Android Studio 2.3.2 instead, and verified the build works there, when using
classpath 'com.android.tools.build:gradle:2.3.2'
Solution:
Was actually able to use Android Studio 3.0 with this small change to the
app/build.gradle
file (to make it work like in Android Studio 2.3.2):jhass commentedon Feb 19, 2018
Now this is why it's worth to regularly spend time on updating dependencies.
arkilis commentedon Jun 17, 2018
@AndSync any reason why the
apply plugin: 'com.jakewharton.butterknife'
caused the issue?bqhub30 commentedon Aug 16, 2018
I found this solution
Change:
compile 'com.jakewharton:butterknife:8.+.+'
into
annotationProcessor 'com.jakewharton:butterknife:8.+.+'
it worked for me
jhass commentedon Aug 16, 2018
🤔
sud007 commentedon Aug 16, 2018
I was solving the 'spot the difference' puzzle by user @bqhub30
But I am also stuck with unable to build ButterKnife !
gallonyin commentedon Nov 12, 2018
Error:
Annotation processors must now be declared explicitly. The following dependencies in the compile classpath are found to contain annotation processors. Please add them to the annotationProcessor configuration.
I found this solution:
tonifirnandes commentedon Aug 5, 2019
Thanks work for me, Specs build gradle:
mahmoud-coo6 commentedon Sep 22, 2019
follow instruction for GitHub repository which worked for me 100% with the latest version here URL: https://github.com/JakeWharton/butterknife
wocoficial commentedon Apr 5, 2021
No meu caso foi apenas o antivírus (KasperSky) que estava filtrando as conexões criptografadas, após desativar voltou ao normal.