Android 梯度同步失败:无法解析配置的所有依赖项';:app:debugRuntimeClasspath';

Android 梯度同步失败:无法解析配置的所有依赖项';:app:debugRuntimeClasspath';,android,Android,我最近将我的Android Studio更新为3.0.1版,并启动了一个新项目,其中包含一个空白活动。gradle同步启动后(我打开项目后),我会在事件日志中收到一条消息: Gradle sync failed: Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'. Could not determine artifacts for com.androi

我最近将我的Android Studio更新为3.0.1版,并启动了一个新项目,其中包含一个空白活动。gradle同步启动后(我打开项目后),我会在事件日志中收到一条消息:

Gradle sync failed: Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
                Could not determine artifacts for com.android.support:appcompat-v7:26.1.0
                Could not get resource 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.aar'.
                Could not HEAD 'https://dl.google.com/dl/android/maven2/com/android/support/appcompat-v7/26.1.0/appcompat-v7-26.1.0.aar'.
                Connect to dl.google.com:443 [dl.google.com/216.58.197.46] failed: Connection refused: connect
                Connection refused: connect
                Consult IDE log for more details (Help | Show Log) (3s 878ms)
我从androidsdkmanager重新安装了支持库,并将maven添加到依赖项中,但到目前为止还无法解决这个问题

构建梯度:

// 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()
    maven { url "https://maven.google.com" }
    }
}

task clean(type: Delete) {
 delete rootProject.buildDir
}
apply plugin: 'com.android.application'

android {
 compileSdkVersion 26
 defaultConfig {
    applicationId "com.example.vishalbisht.test"
    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:design:26.1.0'
 implementation 'com.android.support.constraint:constraint-layout:1.0.2'
 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'
}
应用程序级构建梯度:

// 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()
    maven { url "https://maven.google.com" }
    }
}

task clean(type: Delete) {
 delete rootProject.buildDir
}
apply plugin: 'com.android.application'

android {
 compileSdkVersion 26
 defaultConfig {
    applicationId "com.example.vishalbisht.test"
    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:design:26.1.0'
 implementation 'com.android.support.constraint:constraint-layout:1.0.2'
 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'
}
改变这个

 android {
 compileSdkVersion 26
 defaultConfig {
    applicationId "com.example.vishalbisht.test"
    minSdkVersion 15
    targetSdkVersion 26
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner 
 "android.support.test.runner.AndroidJUnitRunner"
}

并使用以下任意一种
google()
maven
{url“https://maven.google.com“}


阅读我之前的答案

我在应用程序级构建梯度中评论了以下几行,从而绕过了这个问题

   androidTestImplementation 'com.android.support.test:runner:1.0.1'
   androidTestImplementation 'com.android.support.test.espresso:espresso-
   core:3.0.1'
然后它开始工作,不确定这是否是一个可接受的解决方案,但据我所知,我至少可以运行和编译我的代码


同样在Android studio 3.1更新之后,我也没有遇到过这个问题。

将你的Gradle和Gradle版本插件升级到最新版本。并将您的项目迁移到androidx

   classpath 'com.android.tools.build:gradle:3.5.1'
还有格拉德尔

#Mon Nov 04 15:09:35 IRST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip

与问题分享你的
Build Gradle
,发布你的应用级别
Build.Gradle
file@Nilu希望这有帮助。@VishalBisht对于测试用例
buildToolsVersion“27.0.0”
您的错误是
连接到dl.google.com:443[dl.google.com/216.58.197.46]失败:连接被拒绝:连接
尝试与稳定的Internet连接同步不做任何事情Vishal,它可以工作!你介意解释一下为什么我们需要注释掉这两行吗?谢谢。@userchord我当时的理解是,这两个库没有更新以与android版本3.0.1的改进构建过程兼容。你在哪个版本的Android studio上遇到了这个问题?