DataBinding worked very well in my project, But after upgrade Android Studio 2.3 today . Run 'app' failed because following error :
Error:(15, 40) Error: package com.javan.myrecorder.databinding not exist.
import com.javan.myrecorder.databinding.FragmentEventsBinding;
:app:compileMockDebugJavaWithJavac FAILED
I just upgrade android studio and didn't change anything. all plugin is latest! Now my question is, why occurs this error and how could I solve it? any help is welcome!
English is not my mother tongue; please excuse any errors on my part.
EDIT1
Like android project googlesamples/android-architecture
git checkout todo-databinding
and then run ./gradlew assembleDebug to build, build failed because of following error:
complete log of build
EDIT2 I have fixed this problem by following Data Binding broke after upgrade to Gradle 2.3.
in build.gradle(app) add
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
..balabala
dependencies {
apt 'com.android.databinding:compiler:2.3.0'
}
some file in my project:
gradle-wrapper.properties
#Mon Mar 06 10:59:04 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
#petrnohejl #George Mount #Sa-Zad Prasla, Thanks!
android-apt and hence using apt has been deprecated since Android Studio 2.2.
Following the android-apt migration guide, instead add the following to your build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0' // use same gradle version!
annotationProcessor 'com.android.databinding:compiler:2.3.0'
}
If you are using Kolin, instead use:
apply plugin: 'kotlin-kapt'
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0' // use same gradle version!
kapt 'com.android.databinding:compiler:2.3.0'
}
The problem comes in a warning that is difficult to see amongst all of the errors:
Warning:Using incompatible plugins for the annotation processing: android-apt. This may result in an unexpected behavior.
If you remove apt, data binding works.
I have also faced the same issue.
I was using ButterKnife and Dagger!!
Solved as follow
1) Remove from app level gradle file:
apply plugin: 'android-apt'
or apply plugin: 'com.neenbedankt.android-apt'
2) Remove from project level gradle file:
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
3) And simply change "apt to annotationProcessor" as following dependencies:
apt 'com.jakewharton:butterknife-compiler:8.5.1',
apt "com.google.dagger:dagger-compiler:2.5"
To:
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1',
annotationProcessor "com.google.dagger:dagger-compiler:2.5"
Data binding also broke for us following the update to Android Studio v2.3. The GoLang Bind plugin became unable to generate library .aar files
Our problem was resolved via a combination of GoMobile version "+eb90329 Mar 7 2017" update and GoBind plugin revert to version "0.2.6" (although the current version is "0.2.8")
Update GoMobile:
$ go get -u -x golang.org/x/mobile/cmd/gomobile
$ gomobile init -x
Revert GoBind plugin in build.gradle:
plugins {
id "org.golang.mobile.bind" version "0.2.6"
}
This solution is working on systems with go version 1.7.1 and 1.8 as well as Android Studio versions 2.1.2, 2.2.3, and 2.3.
Two things
Revert back your gradel-wrapper.properties distributionUrl to "https://services.gradle.org/distributions/gradle-2.14.1-all.zip"
Change the gradle version classpath to previous version "'com.android.tools.build:gradle:2.2.3'"
P.S. Instant run will stop working on ADT with older gradle version.
I too recently downloaded the latest version of android studio 2.3.3, because I was getting the same error in version 2.2.3 i.e Error:Failed to resolve: com.android.databinding:compiler:2.2.3 ,even in the latest version, I was getting the same error,I checked the project structure, In the File>Project Structure>Project , the Android Plugin version was still 2.2.3, I changed it to 2.3.3 and the build is successful and everything is working smoothly.
I solved this problem by changing my version of gradle to:
classpath 'com.android.tools.build:gradle:3.0.1'
Since I am using Android Studio 3.0.1
Related
After update to Android Studio Chimpmunk, I get the error message on Gradle sync:
Minimum supported Gradle version is 7.3.3. Current version is 7.2.'
In my gradle-wrapper.properties, I have got :
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
In my build.gradle, I have :
classpath 'com.android.tools.build:gradle:7.2.0'
I can't change it to:
classpath 'com.android.tools.build:gradle:7.3.3'
the latest version being found by Android Studio being 7.2.0
If I set:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2.0-bin.zip
I also get the same error (stangely).
I to fix this problem?
Thanks.
ANSWER TO MY QUESTION :
For now, I downgraded both to 7.0.4. Update will probably be possible soon.
I just had this problem and invalidating cache fixed the issue.
Image: Invalidate Cache and restart
file/sync project with Gradle Files
I got this problem too after accepting an auto-update prompt from Android Studio. Weirdly, my machine synced OK but other people's didn't.
The gradle version requirement seems to be imposed by the Android gradle plugin (AGP) versions. So also look in your build.gradle files for this kind of thing:
plugins {
id 'com.android.application' version '7.2.0'
id 'com.android.library' version '7.2.0'
}
I found that the AGP version had got bumped to 7.2.0 by the update, and that must have a requirement of Gradle 7.3.3 (confusing!). Anyway, when I edited the AGP back to 7.1.3, then I could downgrade the base gradle distributionUrl to 7.2 and it all worked again.
So this is a compatible set of versions:
build.gradle
plugins {
id 'com.android.application' version '7.1.3'
id 'com.android.library' version '7.1.3'
}
gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip
I have invalidated cache but it didnt help.
The problem of my setup was a two gradle-wrapper.properties files. Both of them should have same Gradle version but they had different.
yourproject/gradle/wrapper/gradle-wrapper.properties
and
gradle/wrapper/gradle-wrapper.properties
I set the same Gradle version for both of them to the
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
After that issue has gone.
I had the same problem for a project that i havent opened since december 2021, i fixed it by updating the gradle version to 7.4.2 in gradle.wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
and used 7.2.1 for the android gradle plugin version, i've also updated Android Studio to Chipmunk 2021.2.1 Patch 1.
I faced the same issue for Gradle version 7.3.0 (Stable). This is how I solved the issue:
I changed the distribution URL present inside gradle-wrapper.properties file:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
Then removed the following plugin present inside the build.gradle (app module)
apply plugin: 'com.google.gms.google-services'
Finally added this line to the main/AndroidManifest.xml to the activity section:
android:exported="true"
So I've just had the same problem with the incompatible required and current Gradle versions(followed the suggested AGP update). Going back to v7.0.4 has fixed the issue.
However, the answer given by #Khaled has also worked for me.
File > Invalidate Caches > Invalidate and Restart
You have to update to android studio dolphin first (was on chipmunk).
This update support gradle version : 3.2 to 7.3, link here https://developer.android.com/studio/releases/gradle-plugin
Then update gradle-wrapper.properties :
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
Then update your module dependencies as below
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
}
Optional : You will be asked to update gradle plugin to 7.3.1 so you can do it then your will have -> 'com.android.tools.build:gradle:7.3.1'
That's all you need, no invalidate cache and restart or something else.
Install new version Android Studio. It's working for me.
I cloned this project from github and imported it using android studio but after doing all the rounds I'm getting this error
ERROR: Gradle DSL method not found: 'deleteAllActions()'
Can anyone help me remove this error and build the project well?
You should update the version of the Retrolambda plugin. Currently, that would be 3.7.1.
So in your project's build.gradle file, make sure that you have this line:
classpath 'me.tatarka:gradle-retrolambda:3.7.1'
if you are using below dependency for multiple image selection functionality.
react-native-multiple-image-picker
then remove the below line from build.gradle of the same library.
apply plugin: 'me.tatarka.retrolambda'
If you're trying to open the project on Android Studio 3.4.x, then update your android studio to 3.5.1 and re-clone the same project. I had the same issue and after updating, it built the project successfully!
Edit: This is happening specifically when gradle is updated to 5.4.1
To stop this from happening, change this line inbuild.gradle file :
classpath 'com.android.tools.build:gradle:3.5.1'
To this :
classpath 'com.android.tools.build:gradle:2.2.2'
And change this line in gradle-wrapper.properties :
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
To this :
distributionUrl=https\://services.gradle.org/distributions/gradle-3.2.1-bin.zip
Then sync and it will successfully sync the project
Remove dependency me.tatarka:gradle-retrolambda from build.gradle in data module.
I updated my Android Studio version to 3.2. Now I am facing following error for my project - com.novoda.gradle.release.AndroidLibrary$LibraryUsage.getDependencyConstraints()Ljava/util/Set;
Currently I am using gradle version 4.6.
Issue link https://github.com/novoda/bintray-release/issues/177 says to downgrade gradle version to 4.4 but minimum supported version for Android Studio 3.2 is 4.6.
How to resolve this error.
I solved the same error by changing the order of the plugins in your build.gradle file to :
//has to be BEFORE 'com.android.library'
apply plugin: 'com.novoda.bintray-release'
apply plugin: 'com.android.library'
The solution is stated here - Take a look at : Issue III.
While keeping the distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip in my gradle-wrapper.properties file.
This solution worked for me:
As Bintray has fixed the issue in its new release i.e. 0.9 so adding that in build.gradle (project) files removes the error.
classpath 'com.novoda:bintray-release:0.9'
You will either need to downgrade back to AS 3.1.x or attempt the workarounds described on the Novoda issue you linked. Namely this plugin...
I need gradle ver 2.1.4 so I tried changing
classpath 'com.android.tools.build:gradle:2.1.3'
to
classpath 'com.android.tools.build:gradle:2.1.4'
but it didn't work. I also tried this method http://devdeeds.com/update-gradle-plugin-android-studio/ but that didn't work either.
This is the error that I am getting
Error:Could not find com.android.tools.build:gradle:2.1.4. Searched in
the following locations:
file:/C:/Users/Reimu/Downloads/android-studio-ide-145.3200535-windows/android-studio/gradle/m2repository/com/android/tools/build/gradle/2.1.4/gradle-2.1.4.pom
file:/C:/Users/Reimu/Downloads/android-studio-ide-145.3200535-windows/android-studio/gradle/m2repository/com/android/tools/build/gradle/2.1.4/gradle-2.1.4.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.4/gradle-2.1.4.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/2.1.4/gradle-2.1.4.jar
Required by:
:MyApp:unspecified
I can't run any projects without this being updated apparently.
Any help is appreciated
The classpath 'com.android.tools.build:gradle:2.1.3' is not for Gradle itself, but the Gradle Android build plugin that you apply with the apply plugin: 'com.android.application' or apply plugin: 'com.android.library' in your module's build.gradle file.
If you want to use another version of gradle in your project, reconfigure your gradle wrapper. Search for the /gradle/wrapper/gradle-wrapper.properties file in your project root, and apply the correct distributionUrl, for example:
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
For the 2.14.1 version of gradle. This is probably what you need, because there is no such thing as Gradle v. 2.1.4. There is also no Android Gradle plugin v. 2.1.4.
And if it turns out, that you need the newest android grade build plugin, then change your class path to 'com.android.tools.build:gradle:2.2.0-beta2'. Version 2.1.3 is currently the newest stable version.
I'm trying to create a simple android project with gradle. I work in a computer with Debian GNU/Linux 7 'wheezy'.
I followed the recomendations in Gradle Plugin User Guide - Android Tools Project Site, but it casts an error:
FAILURE: Build failed with an exception.
* Where:
Build file '/home/alex/Proyectos/MyLogin/build.gradle' line: 11
* What went wrong:
A problem occurred evaluating root project 'MyLogin'.
> Could not create plugin of type 'AppPlugin'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.817 secs
I followed the specifications:
Gradle 1.9
Plugin 0.7
SDK 17+ (actually 19)
I also started a project anew, and the results I showed were issued by the command gradle tasks as shown in the documentation.
I also tried gradle 1.10, but the result is the same.
Even this question was not usefull, since it solved with 'upgrading' to gradle 1.6 (I understand that plugin 0.7 requires at least gradle 1.9).
I tried this after failing with the same error in android-studio and IntelliJ Idea.
EDIT: I also tried with new projects in both IDEs, and got the same issue. But what most surprises me is that both IDEs use gradle 1.8 in their wrapped form. I tried to cinfigure both of them to use my local gradle install, but still the same issue.
What am I doing wrong? Is it a bug? How can I avoid the problem?
Please, help me.
EDIT: Here is my build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 14
buildToolsVersion '19.0.1'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
}
}
sourceCompatibility = 1.6
version = '0.1'
dependencies {
compile 'com.android.support:support-v4:18.0.0'
//compile project(':core')
}
Google made a mistake with version 0.7.2 of the Gradle plugin:
Note: 0.7.2 requires Java7. This is a mistake. Use 0.7.3 instead.
Release 0.7.3 re-enables Java6 support. Declaring Gradle 0.7.3 in my build files does indeed resolve this for me.
No one is perfect :)
http://tools.android.com/tech-docs/new-build-system
Use Gradle 1.9 instead of Gradle 1.10. There is an issue with 1.10 : https://code.google.com/p/android/issues/detail?id=63822
Also answered here:
Can't find org.gradle.api.artifacts.result.ResolvedModuleVersionResult when apply Android plugin in Gradle
I got it working using Gradle 1.10 with the Gradle plugin 0.8.0.
// /build.gradle
// Top-level build file where you can add configuration
// options common to all sub-projects/modules.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.8.+'
}
}
...
# /gradle/wrapper/gradle-wrapper.properties.
#Sat Feb 01 20:41:29 CET 2014
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-bin.zip
If you're using the command line to create the project like so:
android create project -g -v 1.2.2 --target 1 --name rtest --path rtest --activity MainActivity --package com.mydomain.rtest
The project is created to use version 1.2.2 of the android-gradle-plugin, but the project is initialised with gradle 1.12, which isn't compatible.
To fix it, do the following:
Open rtest/gradle/wrapper/gradle-wrapper.properties and set distributionUrl to the release you want; for example: http\://services.gradle.org/distributions/gradle-2.2.1-all.zip (don't forget to escape the colon - yes, that makes me smile too);
Open build.gradle and change runProguard false to minifyEnabled false;
./gradlew clean && ./gradlew assembleDebug
I also remove the hidden .gradle folder, but I'm not sure if it's necessary
And it all works again.
For those who are using 2.1 version of studio, replace classpath 'com.android.tools.build:gradle:2.1.0-rc1' with classpath 'com.android.tools.build:gradle:2.1.0'. This solved my problem.
If you are attempting to update your Gradle 1.9 project to Gradle 1.10 using
task wrapper(type: Wrapper) {
gradleVersion = '1.10'
}
and command ./gradlew wrapper you will get the same error as above.
Solution is to install Gradle 1.10 onto your machine and upgrade your project not using the wrapper
gradle wrapper
You can also get this error if you update your system gradle and forget to update the Android Studio gradle home.
I got this today when running gradle assembleRelease. I had installed the Ubuntu default of gradle-1.4. This didn't work, so I tried the latest gradle-1.12 and got the same issue.
Downloading and using gradle-1.10 (and matching my gradle-wrapper.properties file to that version) resolved the issue.
This is with Android Studio 0.5.8.
Go to dependencies and just change the dependencies classpath to
classpath 'com.android.tools.build:gradle:2.0.0-beta6'
Rest Gradle will take care. Happy coding :)
Ok i guess android studio has answer for this to get this bug out using GUI,
I had this error like this...
after updating the plugins i was facing another issues while building,
so changes the gradle setting to default as shown in the image,
After this build was successful.