【问题标题】:Android studio gradle .pom file download errorAndroid studio gradle .pom 文件下载错误
【发布时间】:2018-12-07 06:50:00
【问题描述】:

嗨,我来自伊朗,我们不能在没有代理的情况下使用 gradle,但现在我也不能通过代理使用它 模块 build.gradle:

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "test.example.test.com.test"
        minSdkVersion 17
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    // google support library ---------------------------------------------------------------------
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:support-v13:27.1.1'
    implementation 'com.android.support:support-vector-drawable:27.1.1'

}

和项目分级

    buildscript {

    repositories {
        google ()
        jcenter{ url "http://jcenter.bintray.com/" }
        maven { url 'http://repo1.maven.org/maven2' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'


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

allprojects {
    repositories {
        google ()
        jcenter{ url "http://jcenter.bintray.com/" }
        maven { url 'http://repo1.maven.org/maven2' }
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是我得到的错误

1:Cause: dl.google.com:443 failed to respond

2:org.gradle.internal.resource.transport.http.HttpRequestException: Could not GET 'https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.pom'

3Could not GET 'http://jcenter.bintray.com/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.pom'

4Could not GET 'http://repo1.maven.org/maven2/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.pom'.

【问题讨论】:

标签: java android maven gradle jcenter


【解决方案1】:

Gradle 有自己的依赖管理系统,类似于 maven。我认为 gradle 发布插件的某些部分以某种方式得到了 maven 的支持(未验证)。无论您不必担心这种深度,gradle 都会处理它。您的问题是设置代理。你只需要在$projectDir/gradle.properties中设置一些变量,例如:

#http proxy setup
systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost

这可以用来在没有代理的情况下下载依赖项。如果你想使用代理,你可以使用下面的代码而不是上面的代码。

systemProp.https.proxyPort=3128
systemProp.http.proxyHost=192.168.16.2
systemProp.https.proxyHost=192.168.16.2
systemProp.http.proxyPort=3128

代理端口和主机可以随意更改。

【讨论】:

    【解决方案2】:

    我通过编辑 gradle 属性解决了这个问题,我添加了一个代理,但我忘记了这是我的问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-06
      • 2014-11-17
      • 2017-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多