compileSdkVersion 29
ndkVersion "21.3.6528147"
minSdkVersion 21
targetSdkVersion 29
classpath 'com.android.tools.build:gradle:4.0.0'
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
This is my project details,
I'm getting Gradle sync failed on android studio 4.0.0 due to usage of LazyConfigurationUsageContext,
How I can found LazyConfigurationUsageContext in my project to remove.
I want to use latest gradle version, not give me answer to downgrade gradle version as in this link
Gradle sync failed on android studio 4.0
After a long time I found a solution of it
I removed these lines from my project
apply plugin: 'com.novoda.bintray-release'
classpath 'com.novoda:bintray-release:0.9.1'
after removing these lines project successfully upgraded to latest gradle plugin of android studio
Related
When I try to build our Android React Native app, it generates these warnings related to Gradle:
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.
OneSignalPlugin: WARNING: OneSignalPlugin: Downgraded 'com.android.support:33.0.0' -> 28.+ to prevent compile errors! Recommend updating your project's compileSdkVersion!
WARNING:We recommend using a newer Android Gradle plugin to use compileSdk = 33
This Android Gradle plugin (7.2.1) was tested up to compileSdk = 32
I'm not sure why it's complaining about the compileSdkVersion being updated to 33, as that's exactly what I have specified in my build.gradle file:
buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 21
compileSdkVersion = 33
targetSdkVersion = 33
supportLibVersion = "33.0.0"
castFrameworkVersion = "21.0.0"
kotlinVersion = "1.6.0"
...
However, the more pressing issue is that I'm trying to upgrade the Android Gradle plugin to a newer version. In build.gradle I have:
classpath("com.android.tools.build:gradle:7.0.4")
...and in gradle-wrapper.properties I have:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip
I've tried changing build.gradle to use version 7.3.3, however then it fails to find the pom file to download.
> Could not determine the dependencies of null.
> Could not resolve all task dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:7.3.3.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.3.3/gradle-7.3.3.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.3.3/gradle-7.3.3.pom
Required by:
project :
> Could not find com.android.tools.build:gradle:7.3.3.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/7.3.3/gradle-7.3.3.pom
- https://repo.maven.apache.org/maven2/com/android/tools/build/gradle/7.3.3/gradle-7.3.3.pom
Required by:
project : > project :react-native-gradle-plugin
Here is the full build log, in case it helps: https://gist.github.com/justintoth/11b462c7dbe0f51a2e78a62950e2b969
The answer is that there is a difference between the Gradle version (7.4.2 in my case) and the Android Tools Gradle version (7.3.1 in my case.) So in build.gradle I specified:
classpath("com.android.tools.build:gradle:7.3.1")
...and then in gradle-wrapper.properties I have:
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
This now "works", although I ran into many other build and runtime errors while upgrading to React Native 0.70.x so I'm still not there yet...
I noticed that when loading up your project in Android Studio (currently running 3.1 on Canary Channel), it likes to force you to upgrade Gradle Build Tools and sometimes Gradle itself when it detects it isn't using the latest. The 2 pieces I'm talking about are:
In the root build.gradle:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha03'
}
}
And in gradle/wrapper/gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
Note that I do not specify buildToolsVersion in my Gradle scripts (According to google documentation, this means it tries to use the latest version). I like not specifying it because it's 1 less version I have to continuously change in my Gradle scripts.
For the most part, my question is in regards to best practices. For our software, we tag versions we release to production with the mindset that we might need to go back and hotfix any of those releases. When going back to older hotfixes, should I allow Android Studio to upgrade build tools? Or should I prevent it from doing so (assuming I can, maybe by specifying buildToolsVersion manually)? If the latter case, I don't know how to keep Android Studio from continuously prompting me to upgrade in these cases. Sometimes it seems to fail syncing if I don't upgrade the build tools.
What's the best policy here and what are the functional differences between the two main choices I've outlined?
EDIT:
Here is a screenshot of the prompt I get. It's worded in such a way that it sounds like a build will not be possible unless I upgrade the tools:
And if I click "Update manually" to prevent it from doing so, I get:
I think "Cancel and update manually" in update dialog suits your needs.
If canceled once, you can see the message in status line. (Please see test8)
Also, if you have selected to update, you can manually set it lower again, I think.
Selecting "Update manually" causes build error once, but no error seems to happen if build it again. Please see tests 6-8 below.
Selecting lower gradle plugin version also seems having no problem, as I've tested again from test2 after all tests done.
Updated 2017/12/12
Related resources (to check current version):
Gradle
Gradle - releases
Dec 06, 2017
v4.4
Gradle plugin (>= 3.0.0)
NB: Please see Add Build Dependencies Programmatic access section for details.
Google's maven repo - master index com.android.tools.build
Google's maven repo - build tools group index gradle
3.0.1 or 3.1.0-alpha05
POM file url sample (for stable channel, >= 3.0.0):
NB: These are one of paths that gradle will access to get files
https://maven.google.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom or
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
POM file url sample (for alpha channel, >= 3.0.0):
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.0-alpha05/gradle-3.1.0-alpha05.pom
Old gradle plugin (<= 2.3.x)
Maven repo - gradle artifacts
Below here for information:
To see versions:
Android Studio version: Help > About
Gradle plugin version:
build.gradle(Project)
sample: classpath 'com.android.tools.build:gradle:3.1.0-alpha03'
Gradle version:
gradle-wrapper.properties
sample: distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
NB1: Each gradle plugin version has required Gradle version.
See the table in Update Gradle section of this link.
For example: Gradle plugin 3.0.0 requires Gradle 4.1 or higher.
NB2: Some gradle plugin version has required buildToolsVersion, but basically having no relations to it.
For example: Gradle plugin 3.0.0 requires buildToolsVersion 26.0.2 or higher.
NB3: Some gradle plugin version has release notes with "This is a minor update to support Android Studio xxx"
For example: In the section of Gradle plugin 3.0.0
3.0.1 (November 2017)
This is a minor update to support Android Studio 3.0.1
I used same buildToolsVersion (27.0.1) for all tests below.
Android Studio: 2.2.x is 2.2.3 I think.
I used (android-studio-ide-171.4408382-windows) for Android Studio 3.0.x.
,not current one, but I've already downloaded it ago.
Test 1:
Android Studio: 2.2.x
Gradle plugin: 2.3.3
Gradle: 3.3
buildToolsVersion: 27.0.1
buildscript/repositories: jcenter()
build: pass
Test 2:
Android Studio: 3.0.x
Gradle plugin: 2.3.3
Gradle: 3.3
buildToolsVersion: 27.0.1
buildscript/repositories: jcenter()
build: pass
NB: When changing Android Studio version from 2.2.x to 3.0.x for same project, I saw an update dialog, but not the one in the question.
I've selected "Show tomorrow" for it.
Test 3:
Android Studio: 3.0.x
Gradle plugin: 2.3.3
Gradle: 4.2.1
buildToolsVersion: 27.0.1
buildscript/repositories: jcenter()
build: pass
Test 4:
Android Studio: 3.0.x
Gradle plugin: 3.0.1
Gradle: 4.2.1
buildToolsVersion: 27.0.1
buildscript/repositories: jcenter()
build: failed
Gradle sync failed: Could not find com.android.tools.build:gradle:3.0.1.
...
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
NB: Have to change repository settings.
Test 5:
Android Studio: 3.0.x
Gradle plugin: 3.0.1
Gradle: 4.2.1
buildToolsVersion: 27.0.1
buildscript/repositories: google()
build: passed
Test 6:
Android Studio: 3.0.x
Gradle plugin: 3.0.0-alpha9
Gradle: 4.2.1
buildToolsVersion: 27.0.1
buildscript/repositories: google()
Update dialog is shown.
build: failed after choosing "Cancel and update manually"
In message window:
Error:The project is using an incompatible version of the Android Gradle plugin.
Please update your project to use version 3.0.0.
Search in build.gradle files
NB: This is because gradle plugin 3.0.0 or higher is already released.
Test 7:
Android Studio: 3.0.x
Gradle plugin: 3.1.0-alpha03
Gradle: 4.2.1
buildToolsVersion: 27.0.1
buildscript/repositories: google()
Update dialog is NOT shown.
build: failed
Event log:
Gradle sync failed: Could not find org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.4-3.
NB1: Have to add kotlin.
NB2: kotlin requires mavenCentral repository.
See Kotlin - Using Gradle
Test 8:
Android Studio: 3.0.x
Gradle plugin: 3.1.0-alpha03
Gradle: 4.2.1
buildToolsVersion: 27.0.1
buildscript/repositories: google(), mavenCentral()
Update dialog is NOT shown.
build: passed
A message is shown in status line when I click classpath...gradle line in build.config, but no problem.
build.gradle(Project)
buildscript {
repositories {
google()
mavenCentral()
// jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0-alpha03'
// classpath 'com.android.tools.build:gradle:3.0.0-alpha9'
// classpath 'com.android.tools.build:gradle:3.0.1'
// classpath 'com.android.tools.build:gradle:3.0.0'
// classpath 'com.android.tools.build:gradle:2.3.3'
// classpath 'com.android.tools.build:gradle:2.2.0'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.0'
}
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
#distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
#distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-all.zip
#distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip
Status line
"A newer version of com.android.tools.build:gradle than 3.1.0-alpha03 is available: 3.1.0-alpha04"
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
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.
Failed to sync Gradle Project ‚HelloGlass‘
Error: Cause: failed to find target with hash string 'Google Inc.: Glass Development Kit Preview:19' in D:\Project\Android-SDK
Strangly, this error didn’t appear 3 days ago when I last built the project. I haven’t changed anything or used Android Studio since then.
These are the steps that I’ve tried to solve the issue:
restarted Android Studio and tried to build again
made sure that both gradle and my project use the same path for the Android SDK
made sure that I have the Google Glass Development Kit Installed in the SDK Manager (and all other packages for API 19 as well), also deleted and re-installed it
installed the latest Build Tools via the SDK Manager and consequently changed buildToolsVersion „23.0.1“ to „23.0.2“ in my gradle file
Replaced 'com.android.tools.build:gradle:2.0.0-alpha3' in my top-level gradle file with 'com.android.tools.build:gradle:2.0.0-alpha6' since this is the latest version
in gradle-wrapper.properties changed this line distributionUrl=https://services.gradle.org/distributions/gradle-2.8-all.zip
to this line:
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
and chose „use default gradle wrapper“ in the project options
cleared gradle caches in project/gradle and %HOME%/gradle
tried to build a new Google Glass Project from scratch in Android Studio – same problem
This is the relevant part of my gradle file:
android {
compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.helloglass"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
...
And my top-level gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
}
}
I don’t know what else to do. Any help is greatly appreciated!
I haven't found the reason for the problem, but after re-installing both Android Studio and Android SDK I can finally build the project.
Replace
compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
with
compileSdkVersion 23
then rebuild the project, hope it will work