Could not find com.android.tools.build:gradle:3.0.1 - android

When I try to build my project with gradle wrapper I get this error:
./gradlew
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all files for configuration ':app:classpath'.
> Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
https://maven.fabric.io/public/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://maven.fabric.io/public/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
Required by:
project :app
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
The same project builds OK in Android Studio.
I've already checked this and this but I'm using gradle wrapper version 4.1, have added google() repository and even tried setting android.enableAapt2=false. Any other tips? Thanks.
My root build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My gradle-wrapper.properties file:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
UPDATE: Gabriele was right. I'd to add the repository also in the app/build.gradle file:
...
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
...
I guess that I was confused with this stament "To add one of these libraries to your build, include Google's Maven repository in your top-level build.gradle file" in here.

just wanted to leave an extra tip. When I installed Android Studio, I read somewhere that it was recommended to leave this configuration (with the '+' symbol)
build.gradle (project)
dependencies {
classpath 'com.android.tools.build:gradle:+'
.....
#more lines here
}
However, the project I am using uses an old version of gradle, and this line always requested the latest version. Took me a while to figure it out.

Check your proxy setting on Android Studio
File > Settings > Appearance
&
Behavior > System Settings > HTTP Proxy

Here was how I resolved the issue.
Change the root build.gradle file:
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
.....
//other codes here
}

Related

Could not resolve com.android.tools.build:gradle:3.2.1

There is long time I had not developed any Android application (about 5 months) and now I have came back with nativescript. When I have created my first app using nativescript, I encountered this issue:
Executing before-shouldPrepare hook from
C:\Data\ProjectFiles\NativeScript\HeavenlyMinutes\hooks\before-shouldPrepare\nativescript-dev-webpack.js
Skipping prepare. Building project... Gradle build...
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring root project 'HeavenlyMinutes'.
Could not resolve all artifacts for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:3.2.1.
Required by:
project :
Could not resolve com.android.tools.build:gradle:3.2.1.
Could not get resource 'https://plugins.gradle.org/m2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
Could not GET 'https://plugins.gradle.org/m2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection timed out:
connect
Could not resolve com.android.tools.build:gradle:3.2.1.
Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom'.
Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168.243.150] failed: Connection timed out:
connect
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Get more help at https://help.gradle.org
BUILD FAILED in 48s Command gradlew.bat failed with exit code 1
So I have refered to my last projects created and developed using Android Studio. So the problem was there too. I have tested multiple configurations on gradle and for example two of them are mentioned below:
One
gradle.wrapper.properties
#Thu Sep 27 11:34:03 EEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
build.gradle (project dependencies)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://maven.google.com' }
gradlePluginPortal()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://maven.google.com' }
gradlePluginPortal()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Two
gradle.wrapper.properties
#Thu Sep 27 11:34:03 EEST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
build.gradle (project dependencies)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://maven.google.com' }
gradlePluginPortal()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url 'https://maven.google.com' }
gradlePluginPortal()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
and none of them helped me. As my android projects were working before, I think the problem is somewhere else.
Note that the links https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.jar and https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.2.1/gradle-3.2.1.pom that are mentioned in the errors as unreachable links, are downloadable throw internet browser. So I think one possible solution will be to download them manually and put them somewhere in the project (but I have searched a lot how to do this and didn't find anything).
That was all about sanctions. I have tried some sanction-breaker and at last shecan solved my issue.
This answer will be useful only for Iranian users.
Finally, remove the proxy config in gradle.properties in .gradle folder, it words.Hope this answer will be useful.

Missing com.android.tools.build.gradle4.1 in Android Studio

Here is my build.gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
And here is gradle-wrapper:
#Fri Jan 12 02:39:29 EST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-all.zip
The full error trace is here:
Error:FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'CryptoGallery'.
> Could not resolve all files for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:4.1.
Searched in the following locations:
file:/home/xavi/android-studio/gradle/m2repository/com/android/tools/build/gradle/4.1/gradle-4.1.pom
file:/home/xavi/android-studio/gradle/m2repository/com/android/tools/build/gradle/4.1/gradle-4.1.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/4.1/gradle-4.1.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/4.1/gradle-4.1.jar
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1/gradle-4.1.pom
https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/4.1/gradle-4.1.jar
Required by:
project :
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 0s
I took a look in the directory /home/xavi/android-studio/gradle/m2repository/com/android/tools/build/gradle/4.1/ and saw that I do have a gradle 4.1 build, but it doesn't contain a simple .jar like the others do. It's the full download from the official gradle website. It contains many executables, but none labeled gradle-4.1.jar like the others.
Edit: After changing classpath to the correct line, android studio prompts me to update my gralde to 4.4.1, and I get a traceback.
Don't confuse gradle with the androd plugin for gradle.
Change:
classpath 'com.android.tools.build:gradle:4.1'
with:
classpath 'com.android.tools.build:gradle:3.0.1'
More info here.

grade sync failed when i want to import a project

i want to import a project in to android studio but i have an error gradle sync failed .
this is my build.gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
// 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
}
Gradle sync failed: Cause: com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependencyCacheDir(Ljava/io/File;)V
Consult IDE log for more details (Help | Show Log)
i changed the distributionUrl but doesn't solve the problem .
my gradle-wrapper propertice:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
i searched the net for 3-4 hours but there was no solution for my problem that can solve my problem .
Hope it works
File → Settings → Build, Execution, Deployment → Instant Run and uncheck Enable Instant Run.

error with gradle 2.2.1

I updated Android Studio to 1.4.1 version. gradle sync said needs to version 2.2.1.
I downloaded gradle 2.2.1 and in file-->settings-->gradle set use default gradle wrapper and in 'project location/gradle/wrapper/gradle-wrapper.properties' set distributionUrl=https://services.gradle.org/distributions/gradle-2.2.1-all.zip.
but android studio has errors:
Error:A problem occurred configuring root project 'Scanner'.
Could not resolve all dependencies for configuration ':classpath'.
Could not resolve com.android.tools.build:transform-api:2.0.0-deprecated-use-gradle-api.
Required by:
:Scanner:unspecified > com.android.tools.build:gradle:2.2.1 > com.android.tools.build:gradle-core:2.2.1
Could not resolve com.android.tools.build:transform-api:2.0.0-deprecated-use-gradle-api.
Could not parse POM https://jcenter.bintray.com/com/android/tools/build/transform-api/2.0.0-deprecated-use-gradle-api/transform-api-2.0.0-deprecated-use-gradle-api.pom
Content is not allowed in prolog.
what is problem? and how can solve this?
gradle file:
// 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.2.1'
// 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
}
If you are behind a proxy, try Gradle proxy configuration. From the error log you posted it looks like gradle is not able to resolve addresses. Make sure gradle has internet access.
Also you can try the following change in jcenter().
buildscript {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
}
}
allprojects {
repositories {
jcenter {
url "http://jcenter.bintray.com/"
}
}
}
This many a times fixes the issue.

Exception : mergeDebugResources in Android Studio

I got following Error if I try to add dependency in Top - level build.gradle file. This dependency is very much useful to add GCM in project without it GCM won't work:
Dependency :
classpath 'com.google.gms:google-services:1.5.0-beta2'
Error :-
Error:Execution failed for task ':app:mergeDebugResources'.
> Some file crunching failed, see logs for details
If I remove that dependency from top-level build.gradle the project compiles and run successfully.
If I add that file I got the error and Android Studio do not run project.
Please help me to get out of this error.
Edit
Here is my project level build.gradle file:-
// 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-alpha6'
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
classpath 'com.google.gms:google-services:2.0.0-beta5'
// 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
}
try Changing latest version of dependency from HERE:
classpath 'com.google.gms:google-services:2.0.0-beta5'
Also make sure you are setting correct Gradle plugin dependency as well in root project gradle file.
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
So, your final project build.gradle file will look like
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
classpath 'com.google.gms:google-services:2.0.0-beta5'
}
Try this it should help.
buildTypes {
release {
multiDexEnabled true;
}
}
in your Gradle log, if you're getting bad/invalid PNG file then take a look at my answer at Android Studio Gradle 2.0.0-alpha1 build errors
Hope this helps...

Categories

Resources