Attempt to use #BindView for an already bound ID 0 - android

Android Studio Build fails with:
Attempt to use #BindView for an already bound ID 0 on 'mConnectionMessage'
Fragment.java:53: error: Attempt to use #BindView for an already bound ID 0 on 'mConnectionMessage'.
ImageView mConnectionImage;
^
Here's the part of the code that causes the problem:
#BindView(R2.id.display_discovery_state_icon)
ImageView mConnectionImage;

Upgrade the version of butterknife to 10.2.1

Short Answer:
Under:
build.gradle
change:
classpath 'com.android.tools.build:gradle:3.6.0'
to:
classpath 'com.android.tools.build:gradle:3.5.3'
Long Answer:
Android Studio update is the root cause of the issue.
Here's the update:
"To take advantage of the latest features, improvements, and security fixes, we strongly recommend that you update the Android Gradle plugin from the current version 3.5.3 to version 3.6.0 and Gradle to version 5.6.4. Release notes"
which changes:
classpath 'com.android.tools.build:gradle:3.5.3'
to
classpath 'com.android.tools.build:gradle:3.6.0'
and
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
The problem can be reproducible merely by making the above changes manually (not necessarily running the update).
Note:
I could reproduce the problem and fix, both on windows and mac.

Are you using butternife?
In my case, I upgraded to version 10.2.1 (com.jakewharton:butterknife-gradle-plugin:10.2.1) and no longer received the message.
I'm using gradle 3.6.1.

Related

Android Studio, Unable to migrate to AndroidX

I'm having the following error message when trying to do refactor -> migrate to AndroidX
The gradle plugin version in your project build.gradle file needs to
be set to at least com.android.tools.build:gradle:3.2.0 in order to
migrate to AndroidX
Although I have version higher specified in build.gradle...
app/android/build.gradle
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
I have another app/android/app/build.gradle.
I solved it by changing version to 3.4.1 and back to 3.4.2.
now error is gone..
in my case,
apply
classpath("com.android.tools.build:gradle:4.0.1")
instead of
classpath("com.android.tools.build:gradle:${version.gralde}") -> even version.gralde is 4.0.1
:thinking :) maybe android studio can't identity the plugin version if it references to an external value
Only change gradle version of a project may be not enough. Please also check gadle versions of the dependies. Make sure every gradle version of a depency is beyond 3.2.0. Have a try, please.

Unresolved reference: Observable in Android Studio 3.4

Updated to Android Studio 3.4, with Gradle 5.1.1 and Kotlin 1.3.10 as minimum versions. Cannot run project anymore due to reactivex.Observable not being found. Has anyone found a solution?
Was using rxBinding lib, also tried using latest vesions RxJava 2.2.8 and RxAndroid 2.1.1 with no success.
Downgrading the build.gradle(project) from classpath 'com.android.tools.build:gradle:3.4.0' to classpath 'com.android.tools.build:gradle:3.2.1' might be help you
The issue is that you need to use RxJava 2.2.8 and if you check the RxAndroid gradle file they are using the RxJava version 2.2.6 :
https://github.com/ReactiveX/RxAndroid/blob/2.x/rxandroid/build.gradle
If you force RxJava to use version 2.2.8 it will work.
Add to gradle:
implementation 'io.reactivex.rxjava2:rxjava:2.2.8
Yeah the workaround* for me was to downgrade from gradle 5.1.1 to 4.10.1 and also to the latest android gradle plugin prior to 3.4.0, which is 3.3.2.
I did this in gradle/wrapper/gradle-wrapper.properties by changing to the following:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
I then also changed the following in my root build.gradle file:
'com.android.tools.build:gradle:3.4.0' to 'com.android.tools.build:gradle:3.3.2'
Along with the dependency of RxKotlin use this
api 'io.reactivex.rxjava2:rxjava:2.2.0'
Only works for Gradle 5.0 or above
The accepted answer ended up leading me to the solution: leaving the gradle-wrapper.properties intact and don't increase the gradle version at all. We'll see if a future lib update will solve it for gradle 3.4.

Gradle build failing with fabric crashlytics when minify is enabled in Android studio version 3.2 and Gradle version 4.6

Getting the following errors after applying proguard rules:
Could not find method create() for arguments
[crashlyticsStoreDeobsRelease, class
com.crashlytics.tools.gradle.tasks.StoreMappingFileTask,
com.android.build.gradle.internal.scope.BuildArtifactsHolder$FinalBuildableArtifact#1711854a]
on task set of type
org.gradle.api.internal.tasks.DefaultTaskContainer.
It looks like the version of fabric build tools in your build.gradle is set to something like classpath 'io.fabric.tools:gradle:+' which means it always uses the newest available version.
The current version 1.26.0 seems broken so you can temporarily set exact version to 1.25.4: classpath 'io.fabric.tools:gradle:1.25.4'.
Checked a couple of minutes ago, it works.
UPD: new version io.fabric.tools(1.26.1) is released. classpath 'io.fabric.tools:gradle:+' now works well

Android Studio plugin is too old

I was syncing fine and then suddenly when I tried to run a test on a device from Android Studio I started getting the error:
Error:(1, 0) Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable ...
I've looked around and I found from the gradle website that the latest version is 2.10, I tried adding that to my dependencies with no luck. I've tried various version numbers with various errors like the following:
Could not find com.android.tools.build:gradle:2.1
Searched in the following locations ...
I understand from all the searching I've done that its clearly a wrong version of gradle - but what IS the current version label I should be using, and how do I know it is installed on my machine ? I've always kept Android Studio updated.
So I currently have in the build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
}
UPDATED (28/03/2017):
2.4.0-alpha3 is the latest release
classpath 'com.android.tools.build:gradle:2.4.0-alpha3'
Check https://bintray.com/android/android-tools/com.android.tools.build.gradle/view for the latest gradle versions.
2.0.0-alpha1 is on the Canary channel and apparently these releases come with an expiry date. 2.0.0-alpha3 is the latest release. Switch to
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
and you should be fine. Keep checking http://tools.android.com/tech-docs/new-build-system to know the latest releases.
You might run into some Dex error. I had to do Build > Clean Project once to get it to work.
Change your existing configuration with this
In your project view, select Gradle Scripts
Open gradle-wrapper.properties
Change this line:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
with
distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-all.zip
Go to build.gradle (Project: your_app_name)
Change this line
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
to this
classpath 'com.android.tools.build:gradle:1.5.0'
Don't click Sync Now
From menu choose File -> Invalidate Caches/Restart...
Choose first option: Invalidate and Restart
Android Studio would restart. After this, it should work normally
Hope it help
Now com.android.tools.build:gradle:2.0.0-alpha3 is old
use this
com.android.tools.build:gradle:2.0.0-beta2
If your having trouble getting the plugin to resolve. Check that your including jcenter() (Jcenter) in your repositories for the buildscript. Google does not publish the plugin to mavenCentral() (Maven Central).
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
}
}
As others have mentioned the latest ATM is 2.0.0-alpha3 but that could change at any time. Here is the source of truth on the latest available version:
https://jcenter.bintray.com/com/android/tools/build/gradle
As for the actual error here is the best answer is in is link. TLDR, undocumented feature of the non release plugins is they expire and you have to update.
https://stackoverflow.com/a/31293869/873237
Just solved by doing the following steps:
1 - Open gradle-wrapper.properties
Replace
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
with
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
2 - Open build.gradle (Project: app_name)
Replace
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
with
classpath 'com.android.tools.build:gradle:2.2.1'

Android Studio 2.0 - Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to

I updated the Android Studio version 2.0 and was using normally. When I created a new project today, it is displaying the error Plugin is too old, please update to a more recent version, or set ANDROID_DAILY_OVERRIDE environment variable to
I realized that this problem occurs only when I create a new project. In previous projects developed, the problem does not occur and I realized that gradle is different
classpath 'com.android.tools.build:gradle:1.3.0'.
I have to update with the same set of old projects?
My app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "luizugliano.com.br.teste"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}
My build.gradle (Project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
UH OH, Google Notice: "This website no longer provides downloads for Android Studio."
(Old 'channel' links no longer work. Links in this answer have been updated to the new formats, make sure to change your bookmarks if you were using them)
You need to update the version of the gradle tools you are building with. This can be found inside the dependencies section of your build.gradle. You have 3 options you can update to:
The latest stable version referenced in the release channel as of 2nd March, 2017 is
classpath 'com.android.tools.build:gradle:2.3.0'
Or the latest beta version via preview channel as of 15th February, 2017 is
classpath 'com.android.tools.build:gradle:2.3.0-beta4'
And the latest alpha version also from the preview channel as of 21st March, 2017 gives you the option to use
classpath 'com.android.tools.build:gradle:2.4.0-alpha3'
Updating requires you to also upgrade the gradle wrapper. As of 20th February '17, the newest is:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4-all.zip
On android studio you can find your wrapper by changing to the project view and looking in gradle/wrapper/gradle-wrapper.properties
Sometimes after changing wrapper the project will fail to compile with an error like “Minimum supported Gradle version is 2.14.1. Current version is 2.10. Try changing Gradle distribution version to...” despite already having the correct version in gradle-wrapper.properties. If that happens try the following:
Go to Settings > Build, Execution, Deployment > Gradle
Under Project-level settings ensure that Use default gradle wrapper (recommended) is the selected option, then re-build your project.
(Additional Note: With regards to the alpha and beta versions - there is not always a newer build than the stable version when I check, in those cases I've just given values for the previous version. This allows you to roll back to that version if you experience issues with the released version)
In new project change this part:
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
with
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'.
If you're not experienced user, please stick with Android Studio's Updates Stable Channel. I suppose you got Android Studio from Canary Channel.
Note that:
The Canary Channel for Android Studio delivers the bleeding edge updates on a roughly weekly basis. While these builds do get tested,
they are still subject to bugs, as we want people to see what's new as
soon as possible.
From: http://tools.android.com/download/studio/canary
You don't need to change dependencies of your older projects. They should run normally on the latest version.
Same problem on update.
this Fixed it for me:[build.gradle]
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
or
classpath 'com.android.tools.build:gradle:2.0.0-beta2'
Just in Advanced System Settings in Windows Properties, add a new environment variable with the name ANDROID_DAILY_OVERRIDE and the given value in error message. Restart android studio and you will be ready to go
As of April 5, 2016 this worked for me:
classpath 'com.android.tools.build:gradle:2.0.0-rc3'
gradle version you need became
classpath 'com.android.tools.build:gradle:2.0.0-beta7'
Which requires you to use the gradle wrapper for 2.10 if you were still using previous version
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
On android studio you can find your wrapper by changing to the project view and looking in gradle/wrapper/gradle-wrapper.properties
classpath: com.android.tools.build:gradle:+
This will solve the problem by updating gradle to latest one.
However it is dangerous(will code in alpha stage) & will also give warnings.
If you are using Android Studio 2.0 Preview I can suggest using 'beta' updates channel instead of 'stable'. It will allow you to receive latest gradle configuration changes. You can change updates channel in Settings - Appearance & Behavior - System Settings - Updates. Select Automatically check updates for [Beta Channel]
In order to know actual version of gradle classpath and distributionUrl (check Nick Caroso's answer) you can create new empty project and see these values there.
You need to change your gradle-wrapper.properties file in gradle/wrapper folder of your app, change your distributionUrl as this:
distributionUrl=http\://services.gradle.org/distributions/gradle-2.8-all.zip
Use http: or https:\ as per your requirement.
Then just clean your project and you are done!!!
Side Note :
classpath 'com.android.tools.build:gradle:2.0.0-alpha3'
is available now, if you want to use latest version.
Also you can take advantage of instant run feature of android studio using this, which is not available in gradle version below 2.0.0
Android Studio 2.0 has an update project to use instant-run. For those like me with little brains:
http://tools.android.com/tech-docs/instant-run
The current version of Android Studio 2.0 is Beta 6.
try update gradle to 2.10
for mac, tha path is Android Studio > Preferences > Builds,Execution,Deployment > Build Tools > Gradle
of course you must download gradle 2.10 before
I got the same error on 04/07/2016 with
'com.android.tools.build:gradle:2.2.0-alpha2' and gradle wrapper 2.10
then, I just changed to
'com.android.tools.build:gradle:2.2.0-alpha3'
now I have no problems.
Hope this help peple.
I have resolved this way.
Steps:
Open gradle-wrapper.properties file and change distributionUrl to https\://services.gradle.org/distributions/gradle-2.14.1-all.zip.
Open root level build.gradle and change classpath to com.android.tools.build:gradle:2.2.2.
Sync your Android studio project.
Reference screen shot:
Done.
just change
classpath 'com.android.tools.build:gradle:2.0.0-alpha '
or
classpath 'com.android.tools.build:gradle:2.1.0'
I change my classpath from 'com.android.tools.build:gradle:2.2.0-alpha4'
to classpath 'com.android.tools.build:gradle:2.2.0-alpha5'
and clicked "try_again" when the warning appears "unable to find cached classpath" you just click "sync", this worked like a breeze.
This problem occures generally when the IDE(android studio) in which project is build and the project are not in compatible gradle plug in. Please check the link below
http://tools.android.com/tech-docs/new-build-system/version-compatibility
In my case i had created a project using AS 1.0/2.0 version, and later imported in studio version new it gave me error then I opened project in older version of AS it worked.
you can also check http://tools.android.com/tech-docs/new-build-system
File -> Project Structure -> Project -> Android Plugin version = 2.2.3
Working fine of Android Studio 2.2.3

Categories

Resources