I have upgraded the my exiting project Gradle version from older version to "com.android.tools.build:gradle:7.0.4".
After upgrading the build version some of the existing libraries not working.
I got an error like below:
Failed to resolve: com.yarolegovich:discrete-scrollview:1.5.1 Show in
Project Structure dialog Affected Modules: app
Failed to resolve: com.redmadrobot:input-mask-android:6.0.0 Show in
Project Structure dialog Affected Modules: app
Failed to resolve: gun0912.ted:tedpermission:2.2.3 Show in Project
Structure dialog Affected Modules: app
Failed to resolve: com.theartofdev.edmodo:android-image-cropper:2.8.0
Show in Project Structure dialog Affected Modules: app
Failed to resolve: com.wang.avi:library:2.1.3 Show in Project
Structure dialog Affected Modules: app
We recommend using a newer Android Gradle plugin to use compileSdk =
32
This Android Gradle plugin (7.0.4) was tested up to compileSdk = 31
This warning can be suppressed by adding
android.suppressUnsupportedCompileSdk=32 to this project's gradle.properties
The build will continue, but you are strongly encouraged to update
your project to use a newer Android Gradle Plugin that has been tested
with compileSdk = 32 Affected Modules: app
Please help me to get out this error.
Thanks in advance.
in your build.gradle.app file there must be property called compileSdk which could be 31 or 32. change it to smaller values and try again.
I had the same problem. But I just run the project and it ran without any problems. But the errors still persist.
I think the problem is with Android Studio cache.
However, we have to wait until the next update.
Step 1:
Update the Gradle version & all libraries.
Step 2:
Remove allprojects { } from project-level build.gradle file.
Step 3:
Replace project-level repositories {} with below code
repositories {
maven {
url "PROJECT DEPENDENCY URL" Ex. : https://maven.google.com, https://jitpack.io
}
google()
mavenCentral()
gradlePluginPortal()
}
Step 4:
Same repositories {} code we have to add in settings.gradle file like below:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
maven {
url "PROJECT DEPENDENCY URL" Ex. : https://maven.google.com, https://jitpack.io
}
google()
mavenCentral()
gradlePluginPortal()
}
}
Step 5:
Sync Gradle, clean the project & run.
I hope these steps will help you to upgrade the project from the old Gradle version to the new Gradle version 7.0.+.
Add jcenter() in your project level build.gradle like below
allprojects {
repositories {
jcenter()
}}
and
buildscript {
repositories {
jcenter()
}
dependencies {...}}
hope it works, as some of the libraries still in Jcenter()
Related
Actually, I'm trying to create a dependency in android and I'm receiving like No build artifacts found and this is my gradle screenshot:
and this is log receiving from jitpack.io
This is log error
Help me to create dependency. I'm using android studio 4.1
Did you try adding jcenter() as well in your repositories?
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}
./gradlew install
update gradle version
i upgraded to android studio 3.0 from android studio 1.2
currently i cannot work on any of my old projects on android 3.0, been getting a lot of gradle build errors
example
Error:(1, 0) Minimum supported Gradle version is 3.3. Current version is 2.2.1.
Please fix the project's Gradle settings.
Fix Gradle wrapper and re-import projectGradle settings
Android Studio 3.0 using Gradle-4.1 and
Android-gradle-plugin 3.0.0
Find gradle folder inside your project
Open gradle-wrapper.properties and change
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Open root build.gradle file and change in buildscript
classpath 'com.android.tools.build:gradle:3.0.0'
Additionally you need to add google() repo link in project repositories list and buildScript repo list.
repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
jcenter()
google() //<- Add
}
Using the latest Android Studio 3.0 Canary 5
Here's the error:
Error:(1, 1) A problem occurred evaluating project ':app'.
Failed to apply plugin [class 'com.android.build.gradle.api.AndroidBasePlugin']
Android Gradle plugin 3.0.0-alpha5 must not be applied to project [path_to_my_project] since version 3.0.0-alpha5 was already applied to this project
Tried: cleaning, rebuilding, opening/closing. Not working.
any ideas ?
[LATER EDIT]
Solution: Migrate to Canary 8+ and all should be ok.
From this reddit thread, killing daemons fixed the problem for me.
./gradlew --stop
This worked for me:
Deactivate Configuration On Demand
In gradle.properties:
org.gradle.configureondemand=false
Then stop the daemon in a terminal window:
gradlew.bat --stop
Now everything works again.
Versions used:
Android Studio 3.0 Canary 5
gradle: gradle-4.1-milestone-1
android gradle plugin: com.android.tools.build:gradle:3.0.0-alpha5
UPDATE
After upgrading to Android Studio 3.0 Beta 2 I can reactivate Configuration on Demand and everything works fine.
Migrating the gradle version from 3.0.0-alpha5 to 3.0.0-alpha7 saved my day !!
I got the issue and realized the issue related with caches.
You have to invalidate caches of Android studio by select File-> Invalidate Caches/Restart.
It worked for me. The issue was resolved.
Open a terminal and write
./gradlew --stop
In gradle.properties make sure you don't have funny stuff
Notice that there are no custom jvmargs...
org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=false
Include the google() repo in build.gradle (project one)
there's how mine look like
build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
maven { url "http://objectbox.net/beta-repo/" }
}
dependencies {
classpath 'io.objectbox:objectbox-gradle-plugin:0.9.12.1'
classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url 'https://jitpack.io' }
jcenter()
google()
maven { url "http://objectbox.net/beta-repo/" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
lastly the support library versions in the app build.gradle file
build.gradle
...
//----- Support Libs
implementation 'com.android.support:appcompat-v7:26.0.0-beta2'
implementation "com.android.support:design:26.0.0-beta2"
implementation "com.android.support:recyclerview-v7:26.0.0-beta2"
implementation "com.android.support:cardview-v7:26.0.0-beta2"
...
I had the same issue, I closed Android Studio and opened again, I noticed that it automatically applied these changes to the following files and everything worked fine:
build.gradle: changed the class path of Gradle from:
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
}
to
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha5'
}
gradle-wrapper.properties: from
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
to
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
I already tried all the solutions including
Clean,
Rebuild,
Invalidate Project
But nothing is working but i figured it out.
For temporary just downgrade your gradle plugin version to stable version
classpath 'com.android.tools.build:gradle:2.3.2'
Replace your alpha line with this line. And have fun.. :)
I've recently updated the gradle version of my project from 2.14.1 to 3.0. Since then the gradle build is failing every time with this error:
Error:Cause: org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection
Possible causes for this unexpected error include:Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)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.In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.
I've searched google and found some solutions like this one but nothing is working. Does anyone know how to fix it?
Upgrade your gradle build tools to the latest version.
One easy way to do this is to add the latest version of the build tools as a dependency in your build.gradle file, for example:
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-beta1'
}
You can then run gradle tasks and gradle will download everything you need.
After Android Studio 2.2 stable released on Sep 19 2016 , the latest version of the build tools is 2.2.0 . So you can fix it by :
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
}
As Android Studio 2.4 stable is not ready to release yet (May 4 2017), the latest stable version of build tools is 2.3.1 .
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
}
If you update this build tools version to 2.3.* , you should also update gradle wrapper version to 3.3 in /yourProjectRoot/gradle/wrapper/gradle-wrapper.properties file. (i know it is not matching question Gradle build failing after update to 3.0, but i strongly suggest you to use latest build tool as google recommended)
BTW: version 2.3.1 of build tool is only exist on jCenter, not MavenCentral, so if you run into error below when run gradlew command line in terminal
Could not find com.android.tools.build:gradle:2.3.1.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.3.1/gradle-2.3.1.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.3.1/gradle-2.3.1.jar
just replace mavenCentral() with jcenter() like
repositories {
jcenter()
//mavenCentral()
}
For latest update of Android Studio 3.0
In gradle-wrapper.properties(File Name) change URL of distributionUrl to the following:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
If you use gradle plugin 2.1.3,
It's simple to solve:
update your gradle plugin to version 2.2.0-beta1
Notes: this is a beta version, maybe you can get any other issues.
https://discuss.gradle.org/t/classcastexception-in-gradle-nightly-3-0-20160609/17979
Happy coding :)
Okay I got it working. For anyone facing the same problem the way it worked for me is as follows:
Go to your external .gradle folder (for me it was C:\Users\drilon.gradle). Inside caches and daemon folder delete all the version folder (they look like this "2.14.1", or "3.0"). Also go to wrapper -> dists -> delete everything there.
Inside your project root (for me it was C:\Users\drilon\AndroidStudioProjects\PorjectName) go to the .gradle folder and delete everything there.
Rebuild the project
EDIT:
Turns out this solution was setting the gradle version back to 2.14.1. ending0421's solution is the working one.
For latest update of Android Studio 3.3.1 below code work.
1) gradle-wrapper.properties add below line.
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
2)build.gradle in project level add below classpath
dependencies
{
classpath 'com.android.tools.build:gradle:3.1.0'
}
if your gradle version is: 3.0.1 then use below code in your gradle-wrapper.properties distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
if 3.1.2 then use below code in your gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
After 1 hour R&D No Solution as worked for me...
But still i have solution follow this its work 100%
step 1: upgrade your build.gradle(Project:<your project name>)
Example : classpath 'com.android.tools.build:gradle:2.1.3' // old gradle file
classpath 'com.android.tools.build:gradle:2.3.1' // upgraded file
OR
classpath 'com.android.tools.build:gradle:3.1.0'
Step 2 : Upgrade compileSdkVersion buildToolsVersion
Example : compileSdkVersion 23 buildToolsVersion "23.0.3 // old api's
compileSdkVersion 25 buildToolsVersion "25.0.2" // upgraded api's
Step 3: upgrade gradle-wrapper.properties
Example : distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip // old or any version
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip // new or any version
Step 4 : finally goto build>rebuild project...
Still You face some problem commit or inbox me....
......End #Ambilpura
You should check your Gradle Plugin version and Gradle version before updating.
Check Gradle Plugin Version in your project level build.gradle file-
buildscript {
repositories {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:gradle.plugin.version'
}
}
Check Gradle Version in your gradle-wrapper.properties-
distributionUrl=https\://services.gradle.org/distributions/gradle-gradle.version.zip
At the time of this answer, below were the latest versions. You can match your versions on this page.
Simply delete everything inside gradle folder in main project folder and Rebuild the
project. It will start working.
If your gradle plugin 3.0.0 for studio version 3.0, Add this in gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
simple answer try this...
goto build.gradle(PROJECT) and check the gradle version as shown below
'com.android.tools.build:gradle:2.1.3' or 3.0 or 3.1 or xx.xx
now open gradle-wrapper.properties see this line of code if gradle version is 2.x this the code below...
distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip
gradle-2.14.1-all.zip line of code must be same as gradle version
example:
example:
mine is 2.x so...
classpath 'com.android.tools.build:gradle:2.1.3' in build.gradle so
distributionUrl=https://services.gradle.org/distributions/gradle-2.14.1-all.zip
in gradle-wrapper.properties.
if gradle version is 3.x then
classpath 'com.android.tools.build:gradle:3.1.0' in build.gradle then
distributionUrl=https://services.gradle.org/distributions/gradle-3.14.1-all.zip
in gradle-wrapper.properties.
check this it will works
if Android Studio Android Studio 3.0 below code work.
gradle-wrapper.properties add below line.
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
if Android Studio Android Studio 3.1.2 below code work.
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
if Android Studio 3.3.1 below code work.
1) gradle-wrapper.properties add below line.
distributionUrl=https://services.gradle.org/distributions/gradle-4.6-all.zip
2) build.gradle in project level add below
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
}
Android Gradle dependencies are not working in new update of Android
Studio
Most important thing if you are face a lot of problems :
It is applicable on plugin 7.1 or new update version
Please Try this:
Go To -> settings.gradle inside of repositories { } :
add two files as :
maven{ url("https://repo.gradle.org/gradle/libs-releases/") }
maven { url "https://jitpack.io" }
The complete structure in
settings.gradle
file as given below :
pluginManagement {
repositories {
gradlePluginPortal()
google()
mavenCentral()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven{ url("https://repo.gradle.org/gradle/libs-releases/") }
maven { url "https://jitpack.io" }
}
}
rootProject.name = "MyApp"
include ':app'
And last step, it is must be added into gradle.properties files.
android.useAndroidX=true
android.enableJetifier=true
I've just pulled down an Android project from git, and Android Studio is giving me the following error whenever I attempt to open it;
Error:Could not find com.android.tools.build:gradle:2.2.0-alpha6.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0-alpha6/gradle-2.2.0-alpha6.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.0-alpha6/gradle-2.2.0-alpha6.jar
https://maven.fabric.io/public/com/android/tools/build/gradle/2.2.0-alpha6/gradle-2.2.0-alpha6.pom
https://maven.fabric.io/public/com/android/tools/build/gradle/2.2.0-alpha6/gradle-2.2.0-alpha6.jar
Required by:
newApp_Android:app:unspecified
I've installed Gradle locally, and set up environment paths via System.
Under Project Structure/Project, the following setup is in use;
Gradle Version : 2.10
Android Plugin Version : 2.2.0-alpha6
Android Plugin Repository : jcenter
Default Library Repository : jcenter
Could anyone point me in the right direction on this?
This is because the build process is unable to find the dependency in Maven repository. Add jcenter() along with mavenCentral() in your project level build.gradle file.
buildscript {
repositories {
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0'
}
}
So I had a similar error while I was trying to build ionic2 project for android. This happened after android studio updated gradle during its updates.
Error: cmd: Command failed with exit code 1 Error output:
FAILURE: Build failed with an exception.
What went wrong:
A problem occurred configuring root project 'android'.
Could not resolve all dependencies for configuration ':_debugApk'.
A problem occurred configuring project ':CordovaLib'.
Could not resolve all dependencies for configuration ':CordovaLib:classpath'.
Could not find com.android.tools.build:gradle:2.2.3.
Searched in the following locations:
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
Required by:
android:CordovaLib:unspecified
I read the above answers which pointed to update a 'build.gradle' file but turns out there were multiple files with that name in the project. What worked for me (and hopefully helpful to whoever is working on angular2/ionic2 project and having this issue) is updating the build.gradle file at
[rootOfPorject]/platforms/android/CordovaLib/build.gradle
This file was missing the jcenter() entry and now the repository part looks like this and works like a charm.
repositories {
jcenter()
mavenCentral()
}
Hope this saves time for someone else.
EDIT: As #rcerecedar mentioned, you might also need to add jcenter() in the following file as well.
[rootOfPorject]/platforms/android/build.gradle
In this file you should check its present in buildscript -> repositories and also optionally in allprojects -> repositories
1.Goto "C:\Program Files\Android\Android Studio\gradle\m2repository\com\android\tools\build\gradle"
2.See the Latest folder name , i.e "2.2.3" , Copy It.
3.Go to build.gradle(Module:yourapp) file ,
Place here:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
If you have firewall configured in your PC,try the following in gradle.properties.
systemProp.https.proxyHost=<proxyHostName>
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=<user id>
systemProp.https.proxyPassword=<password>
systemProp.https.nonProxyHosts=www.google.com|localhost
What worked for me was i did exactly what "geekydhaval" said, thanks again for that but I went back to the dependencies {
classpath 'com.android.tools.build:gradle:2.3.0' } and change from 2.3.2 to 2.3.0 and the build completed successfully.
Replace the gradle:2.2.0-alpha6 to gradle:2.2.0-alpha3.
If this doesn't work replace it to gradle:2.2.0-alpha2.
As gradle is updating the previous version will be replaced with new version so we have to change the gradle version in code as it would be referring to previous version and will show error like this
Could not resolve all dependencies for configuration ':classpath'.
Could not find com.android.tools.build:gradle:2.2.3.
Searched in the following locations:
file:/home/ubuntu/.m2/repository/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
file:/home/ubuntu/.m2/repository/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
https://repo1.maven.org/maven2/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
https://oss.sonatype.org/content/repositories/snapshots/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.jar
Required by:
:: Open file
The solution to this is that we add the repository in the build.gradle file
like
buildscript {
repositories {
mavenCentral()
google()
jcenter()
}
OR
GOTO the File Explorer and search
C:\Program Files\Android\Android Studio\gradle\m2repository\com\android\tools\build\gradle
and see the Gradle name with latest version like
Gradle 2.2.0
Gradle 3.2.1
Gradle 2.1.0
and select the latest version like 3.2.1 and paste it in the build.gradle file in dependencies section like
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'}