【问题标题】:Failed to resolve: com.android.support:support-compat:27.2.0无法解决:com.android.support:support-compat:27.2.0
【发布时间】:2018-10-17 09:58:42
【问题描述】:

我的 App gradle 中的依赖项有问题:

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "fr.android.MyApp"
    minSdkVersion 16
    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(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:25.1.1'
implementation 'com.android.support:animated-vector-drawable:27.1.1'
implementation 'com.android.support:support-compat:27.2.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-auth:11.6.0'
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'
}
apply plugin: 'com.google.gms.google-services'

出错的行是:

implementation 'com.android.support:animated-vector-drawable:27.1.1'

它说:无法解决:com.android.support:animated-vector-drawable:27.1.1

还有:

我还得到:配置“编译”已过时,已替换为“实现”和“API”。 它将在 2018 年底被删除。

这是我的 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.1.2'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
    classpath 'com.google.gms:google-services:3.1.1'
      }
   }

allprojects {
repositories {
    google()
    jcenter()
   }
}

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

关于如何解决这个问题的任何想法?提前致谢。

【问题讨论】:

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


    【解决方案1】:

    这是因为您使用了旧版本的 appcompat 库 即:

    implementation 'com.android.support:appcompat-v7:25.1.1'
    

    将其版本从 v7:25.1.1 更改为 27.1.1

    示例:

    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:animated-vector-drawable:27.1.1'
    implementation 'com.android.support:support-compat:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    implementation 'com.google.firebase:firebase-auth:11.6.0'
    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'
    }
    

    更改后同步您的项目

    【讨论】:

      【解决方案2】:

      所有 com.android.support 必须使用完全相同的版本规范

      您在版本27.1.1 中使用animated-vector-drawable:27.1.1,在版本27.2.0 中使用support-compat。您应该将它们设为相同的版本。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-01-16
        相关资源
        最近更新 更多