【问题标题】:'com.android.support:appcompat-v7:27.1.1' conflicts with com.google.android.gms:play-services-maps:15.0.1?'com.android.support:appcompat-v7:27.1.1' 与 com.google.android.gms:play-services-maps:15.0.1 冲突?
【发布时间】:2019-01-19 07:39:50
【问题描述】:

我想使用谷歌地图,但依赖项 (com.google.android.gms:play-services-maps:15.0.1) 与 'com.android.support:appcompat-v7:27.1.1' 冲突。 . 谁能帮忙? 这是我的 gradle 文件

apply plugin: 'com.android.application'

android {
  compileSdkVersion 27
  defaultConfig {
    applicationId "com.gamecodeschool.mapso"
    minSdkVersion 18
    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.0'
  implementation 'com.google.android.gms:play-services-maps:15.0.1'
  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'
}

我的顶级构建文件

    // 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.3'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

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

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

【问题讨论】:

  • 为什么我只是投入,至少投入和帮助
  • 您必须至少说明您遇到的错误是什么,以便人们可以提供帮助,冲突可能会以多种不同的方式发生
  • 您可以发布您的应用级build.gradle 文件吗?
  • 我编辑了问题
  • 我添加了它,遗憾的是我仍然有相同的错误消息,'com.android.support:appcompat-v7:27.1.1' 下的红线说“所有 com.android.support 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本 27.1.1、26.1.0。示例包括 com.android.support:animated-vector-drawable:27.1.1 和 com.android.support:support -media-compat:26.1.0

标签: android gradle


【解决方案1】:

我在尝试添加 com.google.android.gms:play-services-base:15.0.1 时遇到了同样的问题。

在终端中,如果您通过 ./gradlew app:dependencies 查找依赖关系树,您会得到以下内容:

+--- com.google.android.gms:play-services-maps:15.0.1
|    +--- com.google.android.gms:play-services-base:[15.0.1,16.0.0) -> 15.0.1
|    |    +--- com.google.android.gms:play-services-basement:[15.0.1] -> 15.0.1
|    |    |    \--- com.android.support:support-v4:26.1.0
|    |    |         +--- com.android.support:support-compat:26.1.0 -> 27.1.0 (*)
|    |    |         +--- com.android.support:support-media-compat:26.1.0

显然,这会导致冲突,解决此问题的方法是切换到com.android.support:appcompat-v7:26.1.0

此外,您还必须降级您的 compileSdkVersiontargetSdkVersion

【讨论】:

    【解决方案2】:

    我有与@Gaurav 相同的建议,但您可以从播放服务中排除冲突的依赖,而不是降级您的支持库。

    implementation 'com.android.support:appcompat-v7:28.0.0'
    
    implementation('com.google.android.gms:play-services-location:16.0.0') {
         exclude group: 'com.android.support', module:'support-v4'
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-10
      • 1970-01-01
      • 2019-03-05
      • 1970-01-01
      • 1970-01-01
      • 2018-11-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多