【问题标题】:Could not resolve com.android.support:appcompat-v7:26.1.0 - Network is unreachable无法解析 com.android.support:appcompat-v7:26.1.0 - 网络无法访问
【发布时间】:2018-02-05 19:03:00
【问题描述】:

我正在尝试在 Android Studio 中构建我的第一个应用,但在使用 Gradle 构建时不断收到以下错误。

Could not resolve com.android.support:appcompat-v7:26.1.0.
Required by:
    project :app
 > Could not resolve com.android.support:appcompat-v7:26.1.0.
    > Could not get resource 'https://maven.google.com/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'.
          > Could not GET 'https://maven.google.com/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'.
                   > Network is unreachable (connect failed)

我在一个代理后面,它可能会阻止连接,但是当使用错误消息中的 URL 检查连接(在设置>代理中)时,它显示Connection Succesful

顶级 build.gradle

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'


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

allprojects {
    repositories {
        maven {
            url 'https://maven.google.com'
        }
        mavenLocal()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

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

build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 26
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:26.1.0'
}

它与代理有关吗?我该如何解决这个错误?

【问题讨论】:

    标签: android proxy android-gradle-plugin


    【解决方案1】:

    代理可能会阻止 SSL 连接。您需要在系统上下载 SSL 证书。
    最简单的方法是关闭您的代理,然后进行构建。然后它应该可以工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-17
      • 2018-04-10
      • 2018-05-07
      • 1970-01-01
      • 2018-05-11
      • 1970-01-01
      • 1970-01-01
      • 2015-05-30
      相关资源
      最近更新 更多