java - 为什么在添加 Firebase 连接时出现实现 'com.android.support:appcompat-v7:28.0.0' 错误?

标签 java android xml firebase android-gradle-plugin

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

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

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

All com.android.support libraries must have the exact same version specification...Found versions 28.0.0,26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and 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 应用

最佳答案

解决办法是:

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'

关于java - 为什么在添加 Firebase 连接时出现实现 'com.android.support:appcompat-v7:28.0.0' 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54038269/

相关文章:

android - fragment 未添加到后台堆栈

android - 1个imageview android上的多个动画

java - 按钮只能在圣诞节后使用

java - 使用 <c :import> with spring views 的可能性

java - Selenium div 属性不断变化,我怎样才能找到这个元素?

android - 使用 Hilt 注入(inject)改造

java - 收集对象数组的属性列表

php - 无法弄清楚如何确定 SimpleXML 节点是否为空

java - Apache Spark 工作线程超时

java - 抛出 HttpStatus.UNAUTHORIZED 的 Spring Controller 会触发 500 Http 错误而不是 401