混合版本可能导致Firebase中的运行时崩溃?

时间:2021-01-24 20:58:44

Following are my gradle files:

以下是我的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'

// Top-level build file where you can add configuration options common to all sub-projects/modules.

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

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
}

Here I added firebase core and firebase messaging both in my project but I am facing

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

"All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 17.1.0, 16.2.0, 16.1.1, 16.0.1, 16.0.0, 15.0.1. Examples include com.google.firebase:firebase-messaging:17.1.0 and com.google.firebase:firebase-iid:16.2.0 less... (⌘F1) There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)"

“所有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 less ...(⌘F1)有一些库,工具和库的组合,不兼容,或者可能导致错误。一个这样的不兼容性是使用不是最新版本的Android支持库版本(或者特别是低于targetSdkVersion的版本)。“

Can you please help me to resolve this issue.

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

2 个解决方案

#1


0  

I was also facing same problem here is how i able to resolve that issue:

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

As gradle is giving warning mixing versions can lead to runtime crashes as well as gradle will give example include so as :

由于gradle给出警告混合版本可能导致运行时崩溃以及gradle将给出示例包括如下:

All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 17.1.0, 16.2.0, 16.1.1, 16.0.1, 16.0.0, 15.0.1. Examples include com.google.firebase:firebase-messaging:17.1.0 and com.google.firebase:firebase-iid:16.2.0 less... (⌘F1) There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)

所有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 less ...(⌘F1)有一些库,工具和库的组合,是不兼容的,或可能导致错误。一个这样的不兼容性是使用不是最新版本的Android支持库版本(或者特别是低于targetSdkVersion的版本)。

as you can see in above statement

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

Examples include com.google.firebase:firebase-messaging:17.1.0 and com.google.firebase:firebase-iid:16.2.0 less...

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

so just add whatever depenedencies are creating version conflict and mentioned by gradle

所以只需添加创建版本冲突的所有依赖项并由gradle提及

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

There may be chances that after adding depenedencies gradle will include more depenedencies so add those dependencies also.

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

Note : Gradle shows this warning because you are using some third party library which is using other

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

#2


0  

In your build.gradle file, in your repo beside:

在build.gradle文件中,在您的repo旁边:

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

add:

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

And according to official documentation, there is no:

根据官方文件,没有:

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

#1


0  

I was also facing same problem here is how i able to resolve that issue:

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

As gradle is giving warning mixing versions can lead to runtime crashes as well as gradle will give example include so as :

由于gradle给出警告混合版本可能导致运行时崩溃以及gradle将给出示例包括如下:

All gms/firebase libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 17.1.0, 16.2.0, 16.1.1, 16.0.1, 16.0.0, 15.0.1. Examples include com.google.firebase:firebase-messaging:17.1.0 and com.google.firebase:firebase-iid:16.2.0 less... (⌘F1) There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion.)

所有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 less ...(⌘F1)有一些库,工具和库的组合,是不兼容的,或可能导致错误。一个这样的不兼容性是使用不是最新版本的Android支持库版本(或者特别是低于targetSdkVersion的版本)。

as you can see in above statement

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

Examples include com.google.firebase:firebase-messaging:17.1.0 and com.google.firebase:firebase-iid:16.2.0 less...

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

so just add whatever depenedencies are creating version conflict and mentioned by gradle

所以只需添加创建版本冲突的所有依赖项并由gradle提及

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

There may be chances that after adding depenedencies gradle will include more depenedencies so add those dependencies also.

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

Note : Gradle shows this warning because you are using some third party library which is using other

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

#2


0  

In your build.gradle file, in your repo beside:

在build.gradle文件中,在您的repo旁边:

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

add:

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

And according to official documentation, there is no:

根据官方文件,没有:

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