Android Studio:Gradle项目同步失败。基本功能将无法正常工作

时间:2019-03-06 03:06:40

标签: android gradle android-gradle

我已经使用了VPN和try it again,但仍然无法正常工作。
如果我直接访问该网站,则可以。请在下面查看stacktrace: enter image description here

enter image description here

1 个答案:

答案 0 :(得分:3)

将此代理信息添加到您的gradle.properties文件中:

systemProp.https.proxyPort=9595
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=9595

并在psiphone之类的vpn中设置高于代理端口(例如9595)。然后同步项目。

mavenCentral()添加到您的build.gradle项目中,如下所示:

buildscript {
    repositories {

        google()
        jcenter()
        mavenCentral()
        maven {
            name 'Sonatype SNAPSHOTs'
            url 'https://oss.sonatype.org/content/repositories/snapshots/'
        }


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

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

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        google()

        maven { url 'https://jitpack.io' }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        flatDir {
            dirs 'libs'
        }
    }
}

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

请参阅此post