簡體   English   中英

添加Firebase連接時,為什么在實現'com.android.support:appcompat-v7:28.0.0'時出現錯誤?

[英]Why I am having ERROR on implementation 'com.android.support:appcompat-v7:28.0.0' when adding Firebase connection?

當我修改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應用

解決方案是:

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'

我通過更改Fire-baseclasspath依賴項的版本解決了我的問題。

最新版本的依賴項與應用程序級別build.gradle implementation 'com.android.support:appcompat-v7:28.0.0'沖突。

我的更改如下

  • 在應用程序級別build.gradle文件implementation 'com.google.firebase:firebase-core:16.0.8' implementation 'com.google.firebase:firebase-core:17.0.1' implementation 'com.google.firebase:firebase-core:16.0.8'

  • 項目級build.gradle文件中的classpath 'com.google.gms:google-services:4.3.0'classpath 'com.google.gms:google-services:4.2.0'

*如果將項目遷移到AndroidX,那么您將能夠使用所有最新的依賴項而不會遇到此類錯誤*

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM