android - Gradle 同步失败;无法解析依赖

标签 android android-studio android-gradle-plugin build.gradle

所以我在打开我的项目时遇到了这个问题,当它尝试同步 gradle 时,它失败了,出现了一堆错误,就像这样:

C:\Users\chgam\AndroidStudioProjects\Clicker\app\build.gradle
    Error:Error:Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform file 'a2e1c0f0b1f12751de0faef0779845e8' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Failed to transform file &#39;a2e1c0f0b1f12751de0faef0779845e8&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform file '2fb0769f609abbf071245de47adfd63b' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Failed to transform file &#39;2fb0769f609abbf071245de47adfd63b&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform file '813170e4070acd24750321f2d7aa30c6' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Failed to transform file &#39;813170e4070acd24750321f2d7aa30c6&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform file '02724237b02d3406161e468d55d0060f' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Failed to transform file &#39;02724237b02d3406161e468d55d0060f&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform file 'df60192a7dbbce1d6e7507d3af3eb98f' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Failed to transform file &#39;df60192a7dbbce1d6e7507d3af3eb98f&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debug/compileClasspath': Failed to transform file 'b068e4e90592ef8aaca000867ae570aa' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Failed to transform file &#39;b068e4e90592ef8aaca000867ae570aa&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Failed to transform file '514da6f0413adfbef88c6938d6426983' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Failed to transform file &#39;514da6f0413adfbef88c6938d6426983&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Failed to transform file '723f5eb711364787317896adc48eee21' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Failed to transform file &#39;723f5eb711364787317896adc48eee21&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Failed to transform file 'a2e1c0f0b1f12751de0faef0779845e8' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Failed to transform file &#39;a2e1c0f0b1f12751de0faef0779845e8&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Failed to transform file '2fb0769f609abbf071245de47adfd63b' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Failed to transform file &#39;2fb0769f609abbf071245de47adfd63b&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Failed to transform file '813170e4070acd24750321f2d7aa30c6' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Failed to transform file &#39;813170e4070acd24750321f2d7aa30c6&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Failed to transform file '02724237b02d3406161e468d55d0060f' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Failed to transform file &#39;02724237b02d3406161e468d55d0060f&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Failed to transform file 'df60192a7dbbce1d6e7507d3af3eb98f' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Failed to transform file &#39;df60192a7dbbce1d6e7507d3af3eb98f&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Failed to transform file 'b068e4e90592ef8aaca000867ae570aa' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Failed to transform file &#39;b068e4e90592ef8aaca000867ae570aa&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Failed to transform file 'espresso-idling-resource-3.0.1.aar' to match attributes {artifactType=android-exploded-aar} using transform ExtractAarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Failed to transform file &#39;espresso-idling-resource-3.0.1.aar&#39; to match attributes {artifactType=android-exploded-aar} using transform ExtractAarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Failed to transform file 'a2e1c0f0b1f12751de0faef0779845e8' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Failed to transform file &#39;a2e1c0f0b1f12751de0faef0779845e8&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Failed to transform file '2fb0769f609abbf071245de47adfd63b' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Failed to transform file &#39;2fb0769f609abbf071245de47adfd63b&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Failed to transform file '813170e4070acd24750321f2d7aa30c6' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Failed to transform file &#39;813170e4070acd24750321f2d7aa30c6&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Failed to transform file '02724237b02d3406161e468d55d0060f' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Failed to transform file &#39;02724237b02d3406161e468d55d0060f&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Failed to transform file 'df60192a7dbbce1d6e7507d3af3eb98f' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Failed to transform file &#39;df60192a7dbbce1d6e7507d3af3eb98f&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Failed to transform file 'b068e4e90592ef8aaca000867ae570aa' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Failed to transform file &#39;b068e4e90592ef8aaca000867ae570aa&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@release/compileClasspath': Failed to transform file 'a2e1c0f0b1f12751de0faef0779845e8' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@release/compileClasspath&#39;: Failed to transform file &#39;a2e1c0f0b1f12751de0faef0779845e8&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@release/compileClasspath': Failed to transform file '2fb0769f609abbf071245de47adfd63b' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@release/compileClasspath&#39;: Failed to transform file &#39;2fb0769f609abbf071245de47adfd63b&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@release/compileClasspath': Failed to transform file '813170e4070acd24750321f2d7aa30c6' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@release/compileClasspath&#39;: Failed to transform file &#39;813170e4070acd24750321f2d7aa30c6&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@release/compileClasspath': Failed to transform file '02724237b02d3406161e468d55d0060f' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@release/compileClasspath&#39;: Failed to transform file &#39;02724237b02d3406161e468d55d0060f&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@release/compileClasspath': Failed to transform file 'df60192a7dbbce1d6e7507d3af3eb98f' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@release/compileClasspath&#39;: Failed to transform file &#39;df60192a7dbbce1d6e7507d3af3eb98f&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@release/compileClasspath': Failed to transform file 'b068e4e90592ef8aaca000867ae570aa' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@release/compileClasspath&#39;: Failed to transform file &#39;b068e4e90592ef8aaca000867ae570aa&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Failed to transform file 'a2e1c0f0b1f12751de0faef0779845e8' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@releaseUnitTest/compileClasspath&#39;: Failed to transform file &#39;a2e1c0f0b1f12751de0faef0779845e8&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Failed to transform file '2fb0769f609abbf071245de47adfd63b' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@releaseUnitTest/compileClasspath&#39;: Failed to transform file &#39;2fb0769f609abbf071245de47adfd63b&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Failed to transform file '813170e4070acd24750321f2d7aa30c6' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@releaseUnitTest/compileClasspath&#39;: Failed to transform file &#39;813170e4070acd24750321f2d7aa30c6&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Failed to transform file '02724237b02d3406161e468d55d0060f' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@releaseUnitTest/compileClasspath&#39;: Failed to transform file &#39;02724237b02d3406161e468d55d0060f&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Failed to transform file 'df60192a7dbbce1d6e7507d3af3eb98f' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@releaseUnitTest/compileClasspath&#39;: Failed to transform file &#39;df60192a7dbbce1d6e7507d3af3eb98f&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>
    Error:Error:Unable to resolve dependency for ':app@releaseUnitTest/compileClasspath': Failed to transform file 'b068e4e90592ef8aaca000867ae570aa' to match attributes {artifactType=jar} using transform AarTransform
<a href="openFile:C:/Users/chgam/AndroidStudioProjects/Clicker/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@releaseUnitTest/compileClasspath&#39;: Failed to transform file &#39;b068e4e90592ef8aaca000867ae570aa&#39; to match attributes {artifactType=jar} using transform AarTransform">Show Details</a>

项目/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 {
            jcenter()
            google()
        }
    }

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

应用/build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "ga.venico.clicker"
        minSdkVersion 21
        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'
    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'
}

到目前为止,我已经尝试过各种设置,多次删除 .gradle 文件,以及基本上我在搜索 google 时发现的所有内容。

有没有人知道为什么会发生这种情况以及如何解决? 这是在保存我的项目并构建我的项目并关闭我的电脑然后在第二天尝试打开它之后发生的。

最佳答案

试试这个

compileSdkVersion 26
buildToolsVersion "26.1.0"

关于android - Gradle 同步失败;无法解析依赖,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48127268/

相关文章:

android - 为什么 Android 模拟器/布局编辑器与 iOS 模拟器/ Storyboard相比太慢?

java - 当我尝试在 android studio 3 上构建 apk 时,它给了我错误

github - 有没有办法使用 git 自动将 Github 中的库更新到 Android Studio 项目中?

java - 错误:Process 'command '/usr/local/android-studio/jre/bin/java'' finished with non-zero exit value 2

用 kotlin 和 React Native 应用程序编写的 Android Native 应用程序

java - appView.addJavascriptInterface() 不适用于 API 17

android - 如何取消我的应用程序创建的 AlarmClock?

android - 如何在动态壁纸上渲染 OpenGL(太难了!)?

android - AGP 3.5与Gradle 6兼容吗?

gradle - Gradle无法下载资源