Can't resolve dependency in Android Studio with jcenter

前端 未结 3 853
离开以前
离开以前 2021-02-06 11:06

Why my program hang on resolving dependency for appDebug in andorid studio? I can\'t resolve any library.

This is my root gradle file:

buildscript {
rep         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-06 11:37

    I faced the exact same issue when I tried to include in my build.gradle the following dependency classpath 'com.google.gms:google-services:3.0.0' in order to have

    buildscript {
      repositories {
          jcenter()
      }
    
      dependencies {
          classpath 'com.android.tools.build:gradle:2.3.0'
          classpath 'com.google.gms:google-services:3.0.0'
      }
    }
    

    I got Timeout on gradle resolution path. So far (when only the classpath to the gradle:2.3.0 was present), I in fact was working with my cache, so I didn't notice that my proxy was not correctly set.

    So I tried to select manual proxy: Settings->Apperance&Behaviour-> System Settings ->Http Proxy with Hostname and port number. So the associated gradle.properties was:

    systemProp.http.proxyHost=proxy.com
    systemProp.http.proxyPort=123    (123 is just an example)
    

    but I still had the problem. Caramba!! So I noticed that the files I needed are located here:

    https://jcenter.bintray.com/com/android/tools/build/gradle/2.3.0/

    but Android studio does not provide a UI to set the proxy on HTTPS so I manually edit the gradle.properties to duplicate the line for https

    systemProp.http.proxyHost=proxy.com
    systemProp.http.proxyPort=123    (123 is just an example)
    systemProp.https.proxyHost=proxy.com
    systemProp.https.proxyPort=123  
    

    And.... it works for me. Don't need to change jcenter to mavenCentral.

提交回复
热议问题