【问题标题】:Mixing versions can lead to runtime crashes in Firebase?混合版本会导致 Firebase 中的运行时崩溃?
【发布时间】:2018-08-04 11:39:03
【问题描述】:

以下是我的 gradle 文件:

apply plugin: 'com.android.application'
apply plugin: 'realm-android'
apply plugin: 'io.fabric'


android {
    compileSdkVersion 27
    buildToolsVersion "27.0.3"
    defaultConfig {
        applicationId "???"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 4
        versionName "1.02"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {

            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    realm {

        syncEnabled = true
    }
}

dependencies {

    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(':EBS')
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:gridlayout-v7:27.1.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'
    implementation 'com.afollestad.material-dialogs:commons:0.9.6.0'
    implementation 'com.android.support:cardview-v7:27.1.1'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.daimajia.swipelayout:library:1.2.0@aar'

    implementation 'com.google.firebase:firebase-messaging:17.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.1'

    implementation 'com.crashlytics.sdk.android:crashlytics:2.9.4'
    implementation 'com.github.amlcurran.showcaseview:library:5.4.3'
}

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

// 顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。

buildscript {

    repositories {
        google()
        jcenter()
        maven {

            url 'https://maven.fabric.io/public'

        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
        classpath "io.realm:realm-gradle-plugin:5.4.1"
        classpath 'com.google.gms:google-services:4.0.2'
        classpath 'io.fabric.tools:gradle:1.25.4'
        classpath 'com.google.android.gms:strict-version-matcher-plugin:1.0.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
        maven {

            url 'https://jitpack.io'
        }
    }
}

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

在这里,我在我的项目中都添加了 firebase 核心和 firebase 消息传递,但我面临

"所有 gms/firebase 库必须使用完全相同的版本 规范(混合版本可能导致运行时崩溃)。成立 版本 17.1.0、16.2.0、16.1.1、16.0.1、16.0.0、15.0.1。例子 包括 com.google.firebase:firebase-messaging:17.1.0 和 com.google.firebase:firebase-iid:16.2.0 少... (⌘F1) 有一些库或工具和库的组合是不兼容的,或者可能导致错误。一种这样的不兼容 正在编译的 Android 支持库版本是 不是最新版本(或者特别是低于您的版本 targetSdkVersion.)"

你能帮我解决这个问题吗?

【问题讨论】:

  • 您是否尝试过清理您的项目?
  • 我试过了,没用。

标签: android firebase android-gradle-plugin dependencies firebase-cloud-messaging


【解决方案1】:

我也面临同样的问题,我是如何解决这个问题的:

由于 gradle 发出警告混合版本可能导致运行时崩溃,并且 gradle 将给出示例包括:

所有 gms/firebase 库必须使用完全相同的版本 规范(混合版本可能导致运行时崩溃)。成立 版本 17.1.0、16.2.0、16.1.1、16.0.1、16.0.0、15.0.1。例子 包括 com.google.firebase:firebase-messaging:17.1.0 和 com.google.firebase:firebase-iid:16.2.0 少... (⌘F1) 有一些 库或工具和库的组合,它们是 不兼容,或者可能导致错误。一种这样的不兼容性是 使用不支持的 Android 支持库版本进行编译 最新版本(或者特别是低于您的 targetSdkVersion。)

正如你在上面的陈述中看到的那样

示例包括 com.google.firebase:firebase-messaging:17.1.0 和 com.google.firebase:firebase-iid:16.2.0 少...

所以只需添加任何导致版本冲突并由 gradle 提及的依赖项

implementation com.google.firebase:firebase-messaging:17.1.0
implementation  com.google.firebase:firebase-iid:16.2.0

添加依赖项后,gradle 可能会包含更多的依赖项,因此也添加这些依赖项。

注意:Gradle 显示此警告是因为您正在使用某些第三方库,而该第三方库正在使用其他库

【讨论】:

  • 我尝试了您的解决方案,但仍然遇到同样的错误。
  • @sAm 您遇到什么相同或不同的错误?
【解决方案2】:

在您的build.gradle file 中,在您旁边的仓库中:

maven { url 'https://jitpack.io' }

添加:

maven { url "https://maven.google.com" }

根据official documentation,没有:

implementation 'com.google.firebase:firebase-iid:16.2.0'

【讨论】:

  • 我尝试了您的解决方案,但仍然遇到同样的错误。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-08-15
  • 1970-01-01
相关资源
最近更新 更多