【发布时间】: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