【问题标题】:all com.android.support libraries must use the exact same version specification found versions 27.1.1, 26.1.0所有 com.android.support 库必须使用与版本 27.1.1、26.1.0 完全相同的版本规范
【发布时间】:2019-03-08 06:52:59
【问题描述】:

我在 sdk 兼容性方面遇到了错误。这是我的代码

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
        defaultConfig {
        applicationId "com.capstone.katugna"
        minSdkVersion 23
        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'
        }
        packagingOptions {
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE-FIREBASE.txt'
            exclude 'META-INF/NOTICE'
        }
    }
    productFlavors {
    }
    }

    dependencies {
        implementation fileTree(include: ['*.jar'], dir: 'libs')
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support:support-media-compat:27.1.1'
        implementation 'com.android.support:support-v4:27.1.1'
        implementation 'com.android.support.constraint:constraint-layout:1.1.2'
        implementation 'com.android.support:support-annotations:27.1.1'
        implementation 'com.google.firebase:firebase-core:16.0.1'
        implementation 'com.google.firebase:firebase-database:16.0.1'
        implementation 'com.google.firebase:firebase-auth:16.0.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'
    }


    apply plugin: 'com.google.gms.google-services'

我在实施“com.android.support:appcompat-v7:27.1.1”中遇到错误。建议示例包括 com.android.support:animated-vector-drawable:27.1.1 和 com.android.support:support-v4:26.1.0

这是我的构建 gradle 项目

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.4'
        classpath 'com.google.gms:google-services:4.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
}

【问题讨论】:

标签: java android-studio firebase-realtime-database


【解决方案1】:

由于多个传递依赖从不同的api/libs中提取而发生版本冲突,您可能需要在模块gradle中强制解析策略为

configurations.all {
    resolutionStrategy.force 'com.android.support:support-annotations:27.1.1'
}

除上述之外,在 gradle 中明确提到的依赖项为

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

【讨论】:

  • 配置部分应该放在哪里?
  • 我在实现 fileTree(include: ['*.jar'], dir: 'libs') 下放置的所有内容都会返回错误
  • 在你的模块的构建文件中并且可以在依赖项之前{...}
【解决方案2】:

我遇到了同样的问题,我不得不将接下来的 2 个库添加到 Gradle 中的依赖项中。我不知道它为什么有效,但它有效。

implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-08-21
    • 2017-11-12
    相关资源
    最近更新 更多