安卓开发工具Android Studio:Gradle无法解决依赖关系问题

3
我正在尝试构建导入的项目。
“Gradle: Resolve dependencies ':app:_debugCompile'” 这个过程一直在运行。
所以我上网搜索了一下,发现我需要在终端中运行 gradlew build --stacktrace --debug。
然后我看到,Android Studio 在某个时候尝试进行以下操作:
Connecting to 10.153.20.12:8080

然后连接失败,构建也失败了。
 FAILURE: Build failed with an exception.
 * What went wrong:
 A problem occurred configuring root project 'MyProject'.
 > Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:1.2.3.
 Required by:           
     :MyProject:unspecified
  > Could not resolve com.android.tools.build:gradle:1.2.3.
     > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/1.2.3/gradle-1.2.3.pom'.
        > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/1.2.3/gradle-1.2.3.pom'.
           > Connection to http://10.153.20.12:8080 refused

P.S.: 其他项目可以顺利构建

P.P.S.: 不同的电脑上也发生了同样的问题

以下是我的app:build.gradle文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "ru.myrunner.myrunner"
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.pkmmte.view:circularimageview:1.1'
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.android.support:cardview-v7:22.2.1'
    compile 'com.google.android.gms:play-services:7.8.0'
    compile 'com.android.support:recyclerview-v7:22.2.1'
}

编辑:显然,问题出在


compile 'com.pkmmte.view:circularimageview:1.1'

请您发布Gradle代码,其中包括以下内容:1. 声明任何远程仓库的代码;2. 声明您项目的依赖项的代码。 - Jolta
@Jolta 已更新。这不是我的项目,但我需要在上面工作。 - Ildar Ishalin
机器是否连接到互联网?在错误信息中的URL看起来是有效的:(https://jcenter.bintray.com/com/android/tools/build/gradle/1.2.3/gradle-1.2.3.pom) - Jolta
@Jolta 奇怪,我无法从浏览器访问它... 可能被阻止了或者出了什么问题。 - Ildar Ishalin
尝试离线构建。文件-->设置-->Gradle-->离线工作。 - Anukool
@Anukool 我试过了-视图:circularimageview没有被缓存,所以我无论如何都无法构建该项目。 - Ildar Ishalin
1个回答

4
答案在gradle.properties文件中,先前的开发者将代理设置放在那里。这就是为什么我的AS无法连接到10.153.20.12:8080。
我只需注释掉该文件中的所有内容,问题就解决了。
circularimageview的问题是因为它是一个新库,所以我的AS必须从互联网上下载它,但由于代理服务器不可用而无法下载。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接