无法使用 jcenter 解决 Android Studio 中的依赖项 [英] Can't resolve dependency in Android Studio with jcenter

查看:72
本文介绍了无法使用 jcenter 解决 Android Studio 中的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我的程序在解决 Andorid Studio 中的 appDebug 依赖项时挂起?我无法解析任何库.

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

这是我的根 gradle 文件:

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()
}
}

这是我的应用程序 gradle :

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'
}

而且我无法解析 junit.而且我无法使用浏览器访问 https://jcenter.bintray.com/(它给了我连接超时,而其他站点返回真实响应).

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

推荐答案

在浪费了一天时间后,我发现这是给伊朗开发者的礼物 :D

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

最后我切换回 mavenCentral(). 通过在我的根 gradle 中更改为 mavenCentral() .并解决了问题.

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

我的根 build.gradle 文件变成了下面的代码:

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()
}
}

mevenCentral 中不存在某些库,因此我们必须向我们的 gradle.properties 文件添加代理,如下所示才能访问 jcenter :D

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

或用于 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

这篇关于无法使用 jcenter 解决 Android Studio 中的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆