erro详情:
无法解决':app @ debug / compileClasspath':无法解析com.android.support:appcompat-v7:26.1.0。
无法解析com.android.support:appcompat-v7:26.1.0。 要求: 项目:app
无法解析com.android.support:appcompat-v7:26.1.0。 无法获得资源' https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'。 无法获得' https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.pom'。 连接到dl.google.com:443 [dl.google.com/127.0.1.2]失败:连接被拒绝:连接 连接被拒绝:连接
=============================================== android studio版本是3.0.1
最后一个错误说明: 连接到dl.google.com:443 [dl.google.com/127.0.1.2]失败:连接被拒绝:连接
拒绝连接:连接
我曾尝试将google()或maven {http:// ....}添加到build.gradle,但它也不起作用。如何重新开始呢?谢谢
======================= 的build.gradle(项目):
// Top-level build file where you can add configuration options common to all sub-projects/modules.
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 {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
============================= 的build.gradle(模块):
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "onlineconfig.umeng.gametools.com.myapplication"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard-rules.pro'
}
}
}
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'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.1'
答案 0 :(得分:0)
你来自中国,谷歌被禁止吗?当您访问链接了Google服务的许多网站(例如,font.googleapis)时,这会让您感觉难以忍受,然后您搜索并执行了一些解决方法,即修改主机以将所有类似Google的网站指向localhost&# 34。
您这样做了,然后当您的Gradle尝试连接Google时,它会将https://dl.google.com解析为127.0.1.2,这是一个本地环回地址。
连接到dl.google.com:443 [dl.google.com/127.0.1.2]失败:连接被拒绝:连接已拒绝连接:连接
要解决此问题,只需在hosts
文件中删除与Google相关的行。
如果您仍然拒绝连接,请了解如何"上网科学"
答案 1 :(得分:0)
我将gradle从v7:26.1.0替换为v7:26. +使用所需版本的库并且android studio开始工作。