如何解决依赖问题?

时间:2020-03-12 11:03:29

标签: android android-studio gradle-dependencies

我正在学习android studio并尝试从一个新项目开始,但是我遇到了一些依赖问题

Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.2.
    <a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not resolve androidx.appcompat:appcompat:1.0.2.">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.fragment:fragment:1.0.0.
    <a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not resolve androidx.fragment:fragment:1.0.0.">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.2.
    <a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not resolve androidx.appcompat:appcompat:1.0.2.">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve androidx.versionedparcelable:versionedparcelable:1.0.0.
    <a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not resolve androidx.versionedparcelable:versionedparcelable:1.0.0.">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debug/compileClasspath': Could not download core.aar (androidx.core:core:1.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not download core.aar (androidx.core:core:1.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debug/compileClasspath': Could not download collection.jar (androidx.collection:collection:1.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not download collection.jar (androidx.collection:collection:1.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debug/compileClasspath': Could not download lifecycle-runtime.aar (androidx.lifecycle:lifecycle-runtime:2.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not download lifecycle-runtime.aar (androidx.lifecycle:lifecycle-runtime:2.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debug/compileClasspath': Could not download lifecycle-common.jar (androidx.lifecycle:lifecycle-common:2.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not download lifecycle-common.jar (androidx.lifecycle:lifecycle-common:2.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debug/compileClasspath': Could not download core-common.jar (androidx.arch.core:core-common:2.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not download core-common.jar (androidx.arch.core:core-common:2.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debug/compileClasspath': Could not download lifecycle-viewmodel.aar (androidx.lifecycle:lifecycle-viewmodel:2.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not download lifecycle-viewmodel.aar (androidx.lifecycle:lifecycle-viewmodel:2.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debug/compileClasspath': Could not download annotation.jar (androidx.annotation:annotation:1.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not download annotation.jar (androidx.annotation:annotation:1.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.test.ext:junit:1.1.0.
    <a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not resolve androidx.test.ext:junit:1.1.0.">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.test.espresso:espresso-core:3.1.1.
    <a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not resolve androidx.test.espresso:espresso-core:3.1.1.">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.2.
    <a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not resolve androidx.appcompat:appcompat:1.0.2.">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.fragment:fragment:1.0.0.
    <a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not resolve androidx.fragment:fragment:1.0.0.">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.2.
    <a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not resolve androidx.appcompat:appcompat:1.0.2.">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve androidx.versionedparcelable:versionedparcelable:1.0.0.
    <a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not resolve androidx.versionedparcelable:versionedparcelable:1.0.0.">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download core.aar (androidx.core:core:1.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not download core.aar (androidx.core:core:1.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download collection.jar (androidx.collection:collection:1.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not download collection.jar (androidx.collection:collection:1.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download lifecycle-runtime.aar (androidx.lifecycle:lifecycle-runtime:2.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not download lifecycle-runtime.aar (androidx.lifecycle:lifecycle-runtime:2.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download lifecycle-common.jar (androidx.lifecycle:lifecycle-common:2.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not download lifecycle-common.jar (androidx.lifecycle:lifecycle-common:2.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download core-common.jar (androidx.arch.core:core-common:2.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not download core-common.jar (androidx.arch.core:core-common:2.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download lifecycle-viewmodel.aar (androidx.lifecycle:lifecycle-viewmodel:2.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not download lifecycle-viewmodel.aar (androidx.lifecycle:lifecycle-viewmodel:2.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not download annotation.jar (androidx.annotation:annotation:1.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debugAndroidTest/compileClasspath&#39;: Could not download annotation.jar (androidx.annotation:annotation:1.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.2.
    <a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not resolve androidx.appcompat:appcompat:1.0.2.">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.fragment:fragment:1.0.0.
    <a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not resolve androidx.fragment:fragment:1.0.0.">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.appcompat:appcompat:1.0.2.
    <a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not resolve androidx.appcompat:appcompat:1.0.2.">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not resolve androidx.versionedparcelable:versionedparcelable:1.0.0.
    <a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not resolve androidx.versionedparcelable:versionedparcelable:1.0.0.">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not download core.aar (androidx.core:core:1.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not download core.aar (androidx.core:core:1.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not download collection.jar (androidx.collection:collection:1.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not download collection.jar (androidx.collection:collection:1.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not download lifecycle-runtime.aar (androidx.lifecycle:lifecycle-runtime:2.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not download lifecycle-runtime.aar (androidx.lifecycle:lifecycle-runtime:2.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not download lifecycle-common.jar (androidx.lifecycle:lifecycle-common:2.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not download lifecycle-common.jar (androidx.lifecycle:lifecycle-common:2.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not download core-common.jar (androidx.arch.core:core-common:2.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not download core-common.jar (androidx.arch.core:core-common:2.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not download lifecycle-viewmodel.aar (androidx.lifecycle:lifecycle-viewmodel:2.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not download lifecycle-viewmodel.aar (androidx.lifecycle:lifecycle-viewmodel:2.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   
    Unable to resolve dependency for ':app@debugUnitTest/compileClasspath': Could not download annotation.jar (androidx.annotation:annotation:1.0.0)
    <a href="Unable to resolve dependency for &#39;:app@debugUnitTest/compileClasspath&#39;: Could not download annotation.jar (androidx.annotation:annotation:1.0.0)">Show Details</a>
    Affected Modules: <a href="openFile:C:/Users/ihass/AndroidStudioProjects/MyApplication3/app/build.gradle">app</a>   

3 个答案:

答案 0 :(得分:0)

尝试重新安装依赖项,请查看Android入门页面: https://developer.android.com/training/basics/firstapp 访问创建Android项目。 就您而言,您只需要一个正确的设置即可。此时请勿绕过步骤。

答案 1 :(得分:0)

  1. 尝试以下步骤:在设置中禁用Gradle离线工作。

    转到“文件”->“其他设置”->“默认设置”->“构建,执行,部署”->“构建工具”->“等级”->“取消选中脱机工作选项”。

  2. 按照Google Build的第一个应用链接进行操作,并逐步进行操作。

    链接1:https://developer.android.com/training/basics/firstapp

    link2:https://www.androidauthority.com/android-studio-tutorial-beginners-637572/

答案 2 :(得分:0)

如果您不想暂时使用appcompat库,可以解决该问题: 实现'androidx.appcompat:appcompat:1.1.0' 只需删除此行即可。