Gradle in Android Studio: Failed to resolve third-party libraries

后端 未结 7 2260
陌清茗
陌清茗 2020-12-09 10:51

I have been trying to switch my project from Intellij to Android Studio, which has required me to create a build.gradle file. I know I can add each of these as a library dep

相关标签:
7条回答
  • 2020-12-09 11:11

    this helps

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

    in projects's gradle

    0 讨论(0)
  • 2020-12-09 11:15

    If you use VPN | Proxy on your system then use your proxy info in the gradle.properties file in your project like the following lines of code:

    # HTTP Proxy
    systemProp.http.proxyHost={Host Address}
    systemProp.http.proxyPort={Port Number}
    systemProp.http.proxyUser={Proxy Username}
    systemProp.http.proxyPassword={Proxy Password}
    systemProp.http.nonProxyHosts={NonProxy Hosts Address} # like: 127.0.0.1,localhost
    
    # HTTPS Proxy
    systemProp.https.proxyHost={Host Address}
    systemProp.https.proxyPort={Port Number}
    systemProp.https.proxyUser={Proxy Username}
    systemProp.https.proxyPassword={Proxy Password}
    systemProp.https.nonProxyHosts={NonProxy Hosts Address} # like: 127.0.0.1,localhost
    

    Now just replace {.....} in the above code with appropriate data


    Also you can set Android studio proxies like the following image by your proxy info in File>Settings:

    Now test again...!

    0 讨论(0)
  • 2020-12-09 11:20

    Just to share infomation, I got same problem and the solution was different.

    In my case, proxy server was used and it causes the problem. I needed to configure https proxy settings, as discussed in gradle behind proxy in Android Studio 1.3.

    0 讨论(0)
  • 2020-12-09 11:20

    Maybe this help

    allprojects {
        repositories {
            jcenter()
        }
    }
    
    0 讨论(0)
  • 2020-12-09 11:21

    Add:

    repositories {
       mavenCentral()
    }
    

    to the build.gradle. Now you have repositories defined only in build script which resolves dependencies only for the buildscript itself not for the project.

    0 讨论(0)
  • 2020-12-09 11:30
    repositories {
    jcenter {
        url "http://jcenter.bintray.com/"
    }
    

    // mavenCentral() }

    0 讨论(0)
提交回复
热议问题