Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

gradle

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.

like image 756
FGarcia Avatar asked Jan 30 '18 14:01

FGarcia


People also ask

Where is the Android Gradle plugin in Maven Central?

It seems the current versions of the Android Gradle plugin are not added to Maven Central, but they are present on jcenter. Add jcenter()to your list of repositories and Gradle should find version 2.2.3.

How to add Google to Gradle repository?

1. Add google () to buildscript -> repositories 2. Set distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip in gradle-wrapper.properties Cannot create custom BOM.

Where can I find the distribution URL for Gradle- wrapper?

Set distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip in gradle-wrapper.properties Cannot create custom BOM. Project build fails with Non-resolvable import POM: Could not find artifact

Is there a Gradle bin path in system variables?

One thing that I was missing was the gradle bin path in my System Variables. I had it only in my user variable PATH. Downloading gradle 4.10 and adding the same to System Environment Variable PATH did it for me.


1 Answers

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.

like image 199
Sofia Arrambide Avatar answered Oct 06 '22 08:10

Sofia Arrambide