Can't resolve dependency in Android Studio with jcenter

前端 未结 3 852
离开以前
离开以前 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:26

    After long hours of investigation solution came to me unexpectedly. - Try building your gradle with different network or mobile hotspot. Works for me.

    0 讨论(0)
  • 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<blabla>.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<blabla>.com
    systemProp.http.proxyPort=123    (123 is just an example)
    systemProp.https.proxyHost=proxy<blabla>.com
    systemProp.https.proxyPort=123  
    

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

    0 讨论(0)
  • 2021-02-06 11:41

    After one day time wasting i found that it's gift for Iranian developer :D

    Finally i switch back to mavenCentral().by changing to mavenCentral() in my root gradle . and problem solved.

    My root build.gradle file turn to below code:

    buildscript {
    repositories {
    
       mavenCentral()
    
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
    }
    }
    
    allprojects {
    repositories {
        mavenCentral()
    }
    }
    

    Some library don't exist in mevenCentral so we have to add proxy to our gradle.properties file like below to access jcenter :D

    systemProp.http.proxyHost=www.somehost.org
    systemProp.http.proxyPort=8080
    systemProp.http.proxyUser=user
    systemProp.http.proxyPassword=password
    systemProp.http.nonProxyHosts=localhost
    systemProp.http.auth.ntlm.domain=domain
    

    Or for https

    systemProp.https.proxyHost=www.somehost.org
    systemProp.https.proxyPort=8080
    systemProp.https.proxyUser=user
    systemProp.https.proxyPassword=password
    systemProp.https.nonProxyHosts=localhost
    systemProp.https.auth.ntlm.domain=domain
    
    0 讨论(0)
提交回复
热议问题