【问题标题】:Why I am having ERROR on implementation 'com.android.support:appcompat-v7:28.0.0' when adding Firebase connection?添加 Firebase 连接时,为什么我在实现“com.android.support:appcompat-v7:28.0.0”时出现错误?
【发布时间】:2019-01-04 11:40:21
【问题描述】:

当我修改我的 build.gradle 文件以使用 Firebase 插件时,它在实现 'com.android.support:appcompat-v7:28.0.0' 时显示错误

我已经将 google-services.json 文件添加到我的 Android 应用模块根目录中。

我的错误: 问题 ID= Gradle 兼容

所有 com.android.support 库必须具有完全相同的版本 规范...找到版本 28.0.0,26.1.0。例子包括 com.android.support:animated-vector-drawable:28.0.0 和 com.android.support:support-media-compat:26.1.0

我已尝试将其注释掉:

//noinspection GradleCompatible

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

但它也无法与 firebase 服务器通信

apply plugin: 'com.android.application'

android {
compileSdkVersion 28

defaultConfig {
    applicationId "com.example.android.tinder"
    minSdkVersion 15
    targetSdkVersion 28
    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:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
implementation 'com.lorentzos.swipecards:library:1.0.9'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-auth:16.1.0'
}
apply plugin: 'com.google.gms.google-services'

我的 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.2.1'
    classpath 'com.google.gms:google-services:4.2.0'

    // 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
 }

我只是希望能够将我的 Firebase 连接到我的 android 应用

【问题讨论】:

  • 包括这个:实现 'com.google.firebase:firebase-auth:16.1.0'
  • 仍然有同样的错误
  • 你在 gradle-wrapper.properties 中的 gradle 版本是什么?
  • distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists
  • 尝试删除 'com.lorentzos.swipecards:library:1.0.9' 库。因为,该库的 buildToolsVersion 是“22.0.1”。

标签: java android xml firebase android-gradle-plugin


【解决方案1】:

解决办法是:

implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
implementation 'com.android.support:design:28.0.0'

implementation 'com.android.support:support-media-compat:28.0.0' // NEED TO ADD
implementation 'com.android.support:support-v4:28.0.0' //NEED TO ADD

implementation 'com.google.firebase:firebase-storage:16.0.5'

【讨论】:

    【解决方案2】:

    我通过更改 Fire-baseclasspath 依赖项的版本解决了我的问题。

    最新版本的依赖与应用层build.gradle中的implementation 'com.android.support:appcompat-v7:28.0.0'冲突。

    我的改动如下

    • 在应用级build.gradle 文件中implementation 'com.google.firebase:firebase-core:17.0.1'implementation 'com.google.firebase:firebase-core:16.0.8'

    • classpath 'com.google.gms:google-services:4.3.0'classpath 'com.google.gms:google-services:4.2.0' 在项目级别 build.gradle 文件中。

    * 如果您将项目迁移到 AndroidX,那么您将能够使用所有最新的依赖项而不会遇到此类错误 *

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-01-04
      • 1970-01-01
      • 1970-01-01
      • 2019-04-05
      • 1970-01-01
      • 1970-01-01
      • 2020-05-12
      相关资源
      最近更新 更多