有人可以帮我解决android studio上的这个gradle错误吗?

时间:2017-02-06 14:05:51

标签: android android-studio

当我尝试在android studio上运行我的项目时,我得到错误此错误。有人能帮助我吗?

Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not find any version that matches com.android.support:cardview-v7:23.4.0.+.
     Versions that do not match:
         25.1.1
         25.1.0
         25.0.1
         25.0.0
         24.2.1
         + 22 more
     Searched in the following locations:
         file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/support/cardview-v7/maven-metadata.xml
         file:/C:/Program Files/Android/Android Studio/gradle/m2repository/com/android/support/cardview-v7/
         https://jcenter.bintray.com/com/android/support/cardview-v7/maven-metadata.xml
         https://jcenter.bintray.com/com/android/support/cardview-v7/
         file:/C:/Users/EDUdigital/AppData/Local/Android/sdk/extras/android/m2repository/com/android/support/cardview-v7/maven-metadata.xml
         file:/C:/Users/EDUdigital/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/cardview-v7/maven-metadata.xml
         file:/C:/Users/EDUdigital/AppData/Local/Android/sdk/extras/google/m2repository/com/android/support/cardview-v7/
     Required by:
         AppTraining:app:unspecified

3 个答案:

答案 0 :(得分:0)

您需要安装" Android支持信息库"在SDK Manager中。如果情况并非如此您需要在gradle文件中更改依赖项的版本。

答案 1 :(得分:0)

以此为例:

我的build.gradle,将SDK编译为API 25,因此它需要25+版本的依赖项。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 25
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:25.1.1'
    compile 'com.android.support:design:25.1.1'
    compile 'com.android.support:cardview-v7:25.1.1'
    compile 'com.android.support:recyclerview-v7:25.1.1'
}

版本取决于您要编译的API版本。我会指定一个特定的版本,而不是.+,所以在你的情况下你可以做compile 'com.android.support:cardview-v7:24.0.0'

答案 2 :(得分:0)

您可以通过解决问题来解决 enter image description here 在这里单击“向AndroidX迁移”,然后在出现问题的红线上单击,查看android提供的解决方案,例如更新到较新版本,导入类。