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

一个人想着一个人 提交于 2020-02-02 11:08:32

问题


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).


回答1:


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.




回答2:


Finally, remove the proxy config in gradle.properties in .gradle folder, it words.Hope this answer will be useful.



来源:https://stackoverflow.com/questions/53837101/could-not-resolve-com-android-tools-buildgradle3-2-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!