无法解决依赖项':app@debug/compileClasspath':无法解析com.android.support:appcompat-v7:28.0.0-rc01

19

我在我的新Android Studio版本中遇到以下错误,基本的Hello world也无法在gradle中构建。你能帮我解决这个问题吗?

下面是我在新版Android Studio中遇到的错误:

This is the error I am getting in new android studio version

我的gradle文件如下所示

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "payments.com.java.payments"
        minSdkVersion 17
        targetSdkVersion 28
        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:28.0.0-rc01'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

这是我收到的日志

无法解决“:app@debug/compileClasspath”的依赖关系:无法解决com.android.support:appcompat-v7:28.0.0-rc01。 打开文件 显示详细信息

无法解决“:app@debug/compileClasspath”的依赖关系:无法解决com.android.support.constraint:constraint-layout:1.1.2。 打开文件 显示详细信息

无法解决“:app@debugAndroidTest/compileClasspath”的依赖关系:无法解决com.android.support.test:runner:1.0.2。 打开文件 显示详细信息

无法解决“:app@debugAndroidTest/compileClasspath”的依赖关系:无法解决com.android.support.test.espresso:espresso-core:3.0.2。 打开文件 显示详细信息

无法解决“:app@debugAndroidTest/compileClasspath”的依赖关系:无法解决com.android.support:appcompat-v7:28.0.0-rc01。 打开文件 显示详细信息

无法解决“:app@debugAndroidTest/compileClasspath”的依赖关系:无法解决com.android.support.constraint:constraint-layout:1.1.2。 打开文件 显示详细信息

无法解决“:app@debugUnitTest/compileClasspath”的依赖关系:无法解决com.android.support:appcompat-v7:28.0.0-rc01。 打开文件 显示详细信息

无法解决“:app@debugUnitTest/compileClasspath”的依赖关系:无法解决com.android.support.constraint:constraint-layout:1.1.2。 打开文件 显示详细信息

无法解决“:app@release/compileClasspath”的依赖关系:无法解决com.android.support:appcompat-v7:28.0.0-rc01。 打开文件 显示详细信息

无法解决“:app@release/compileClasspath”的依赖关系:无法解决com.android.support.constraint:constraint-layout:1.1.2。 打开文件 显示详细信息

无法解决“:app@releaseUnitTest/compileClasspath”的依赖关系:无法解决com.android.support:appcompat-v7:28.0.0-rc01。 打开文件 显示详细信息

无法解决“:app@releaseUnitTest/compileClasspath”的依赖关系:无法解决com.android.support.constraint:constraint-layout:1.1.2。 打开文件 显示详细信息


1
请分享您的Gradle文件。而不是粘贴屏幕截图,请将堆栈跟踪粘贴在文本中。 - Abubakar
1
我建议使用androidx.appcompat:appcompat库代替com.android.support:appcompat-v7,因为支持库在28.0.0之后将不再获得更新。 - tyczj
更新了包含Gradle文件和日志的问题。 - user2454202
@tyczj 那并没有帮助。我仍然有这个问题,而且不仅仅是与appcompat有关的问题。以下所有元素都失败了implementation 'com.android.support:appcompat-v7:28.0.0-rc01' implementation 'com.android.support.constraint:constraint-layout:1.1.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' - user2454202
15个回答

0
请参考我创建的这个Youtube视频,作为解决这个问题的方案。

https://www.youtube.com/watch?v=ZAYtPzjDSQU&feature=youtu.be

以下是您的 Gradle 应该配置的样子。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "payments.banamex.citi.com.banamexpayments"
        minSdkVersion 17
        targetSdkVersion 27
        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:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

在链接自己的YouTube视频时,您必须添加披露声明。否则,这可能被视为垃圾邮件。 - Zoe stands with Ukraine
感谢 @Zoe 的建议。 - Abhishek Singh

0
如果不支持28版本,则需要将编译和目标版本更改为27。

0

当我创建一个新项目并标记了androidx,但是我连接到互联网时遇到了类似的问题。简单的解决方案就是连接到互联网并再次同步项目。哇,它可以无错误地构建。你可以试试。


0

我之前也遇到了同样的问题,解决方法是用另一个正常工作项目的依赖文件替换掉原来的依赖文件。只需将该项目的依赖 gradle 文件替换 gradle 中的依赖文件即可。


-1

"无法解决依赖项':app@debug/compileClasspath':无法解决com.android.support:appcompat-v7:28.0.0-rc02。"

这是我在Gradle中遇到的错误,只需连接到互联网即可轻松解决。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接