Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't resolve dependency in Android Studio with jcenter

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 {
repositories {

    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:1.5.0'

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

allprojects {
repositories {
    jcenter()
}
}

and this is my app gradle :

apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
    applicationId "com.example.alimohammadi.myapplication"
    minSdkVersion 15
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
}

And I can't resolve junit. And I can't access to https://jcenter.bintray.com/ with my browser (it gave me connection time out while other site return true response).

like image 331
Ali mohammadi Avatar asked Feb 06 '16 16:02

Ali mohammadi


1 Answers

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
like image 95
Ali mohammadi Avatar answered Sep 27 '22 23:09

Ali mohammadi