代码之家  ›  专栏  ›  技术社区  ›  Fahim

Firebase库必须使用准确的版本错误

  •  -1
  • Fahim  · 技术社区  · 8 年前

    我想使用谷歌云消息推送通知android应用程序。我阅读了下面的文件并为我的申请设置了firebase。我的gradle建造成功了 implementation 'com.google.firebase:firebase-core:16.0.1' 部分,我得到以下错误:

    所有gms/firebase库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本17.1.0、16.2.0、16.1.1、16.0.1、16.0.0、15.0.1。例子包括com.google.firebase网站:火基-消息:17.1.0和com.google.firebase网站:火基-iid:16.2.0以下。。。(Ctrl+F1) 有些库、工具和库的组合是不兼容的,或者可能导致bug。其中一种不兼容是使用非最新版本(尤其是低于targetSdkVersion的版本)的Android支持库进行编译

    应用程序等级:

    apply plugin: 'com.android.application'
    
    android {
    compileSdkVersion 26
    defaultConfig {
        applicationId "notificationtest.com.test.notification"
        minSdkVersion 14
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    }
    
    dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.firebase:firebase-messaging:17.1.0'
    }
    
    
    apply plugin: 'com.google.gms.google-services'
    

    gradle项目:

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

    构建脚本{

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.google.gms:google-services:4.0.1'
    
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
    }
    
    allprojects {
    repositories {
        maven {
            url "https://maven.google.com" // Google's Maven repository
        }
        google()
        jcenter()
    }
    }
    
    task clean(type: Delete) {
    delete rootProject.buildDir
    }
    

    问题是什么?我如何解决?

    1 回复  |  直到 8 年前
        1
  •  -1
  •   manish poddar    8 年前

    您已经添加了两个不同版本的firebase库。

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

    请将其更改为相同的版本,即15.0.2 我只使用这个版本,直到现在才遇到问题。如果需要,也可以使用16.0.1进行消息传递。谷歌可能没有发布firebase core的17版。

    推荐文章