Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

gradle

I'm forcing gradle to use http I have modified my gradle-wrapper.properties:

distributionUrl=http\://services.gradle.org/distributions/gradle-4.3-all.zip

The build.gradle:

buildscript {
repositories {
    //jcenter()
    //google()
    maven { url "http://jcenter.bintray.com"}     
    }
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 {
    jcenter()
    maven { url 'http://maven.google.com' }
    maven { url "http://jitpack.io" }
}}

As far as I'm aware I should use 3.0.1 but when I check the actual repo on jitpack or maven only up to 2.3.3 is available.

The error message I'm getting is:

> Could not resolve all files for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.0.1.
Searched in the following locations:
http://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom
http://jcenter.bintray.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.jar
Required by:
     project :* Try:

Gradle version is 4.3.1 JVM 9.0.1

What can be done to successfully run 'gradle test' here?

EDIT: uncommenting //google() reveled:

       > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
        > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.

When modified the http repo

buildscript {
repositories {
    //jcenter()
    //google()
    maven { url "http://jcenter.bintray.com"}
    maven { url "http://maven.google.com"}

    }

I got:

      > Could not resolve com.android.tools.build:gradle:3.0.1.
     > Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
        > Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
           > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
  > Could not resolve com.android.tools.build:gradle:3.0.1.
     > Could not get resource 'http://maven.google.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
        > Could not GET 'http://maven.google.com/com/android/tools/build/gradle/3.0.1/gradle-3.0.1.pom'.
           > sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

I get the same if I uncomment both jcenter() and google(). Besides, when I check https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/ the link is dead. Now the jcenter repo https://repo1.maven.org/maven2/com/android/tools/build/gradle/ ends on 2.3.3 version which seems to be correct that this error is happening, the question is what is wrong then?

EDIT- Likely solution the issue happenned because you can't run those excluding https completely, it will fail either way.

like image 990
kol23 Avatar asked Jan 16 '18 08:01

kol23


People also ask

Why can't I build apps in Gradle?

This kind of issue usually appears either due to a gradle misconfig or in your case, it looks more of an internet issue. Try running flutter clean in your project source and then using flutter build appbundle and check whether you're able to run the command without any errors.

Why doesn't Gradle get the correct proxy settings for unity?

As far as I know, Unity does not pass proxy settings to other tools that it starts, so in this case Gradle does not get correct proxy settings. You can try to use Android Studio once again. Export your project in Unity, then open it in Android Studio and build once. If the build will succeed, then the dependencies will be downloaded and cached.

Is 'enabler8=false' deprecated in Gradle?

WARNING: The option setting 'android.enableR8=false' is deprecated. It will be removed in version 5.0 of the Android Gradle plugin. Rethrow as BuildFailedException: Exception of type 'UnityEditor.Build.BuildFailedException' was thrown.

Where does the Gradle plugin get its files?

When gradle plugin is cached, it gets placed in .gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle and in .gradle/caches/modules-2/files-2.1/com.android.tools.build/gradle-api There could be other locations where things are cached inside of .gradle/caches, but these two locations are what I was able to find.


Video Answer


3 Answers

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

Read Google's Maven repository

Include Google's Maven repository in your top-level build.gradle file:

FYI

allprojects {
    repositories {
        google()

        // If you're using a version of Gradle lower than 4.1, you must instead use:
        // maven {
        //     url 'https://maven.google.com'
        // }
        // An alternative URL is 'https://dl.google.com/dl/android/maven2/'
    }
}

So, According to your version your build.gradle will

buildscript 
{

    repositories {
        jcenter()
        google()
        maven { url "http://jcenter.bintray.com"}     
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'

    }
}

allprojects 
{
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
like image 151
IntelliJ Amiya Avatar answered Oct 07 '22 11:10

IntelliJ Amiya


I got the same issue and i solved it by making changes main gradle file, as per suggestion given by android studio

buildscript {
    repositories {
        jcenter()

        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
    }
}

allprojects {
    repositories {
        jcenter()
        google()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

gradle-wrapper.properties :

distributionUrl=  https\://services.gradle.org/distributions/gradle-4.1-all.zip

my gradle file is like this, make like this in you project it would most probably work.

Thank you.

like image 40
Sagar Gadani Avatar answered Oct 07 '22 10:10

Sagar Gadani


What worked for me was to remove jcenter() and revert Gradle to an earlier version.

Unfortunately the latest stable version in bintray is 2.3.3 , but atleast I was able to build successfully.

My build.gradle now looks like this:

buildscript {
    repositories {
        maven { url "http://jcenter.bintray.com"}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url "http://jcenter.bintray.com"}
    }
}
like image 3
Hristo Stoyanov Avatar answered Oct 07 '22 10:10

Hristo Stoyanov