从GCM迁移时,FirebaseApp初始化失败

时间:2016-07-11 14:42:12

标签: android firebase firebase-cloud-messaging

所以,我在我的应用程序中实现了GCM,现在我正在尝试将我的应用程序迁移到FCM。完成所有步骤后,我开始看到I/FirebaseInitProvider: FirebaseApp initialization unsuccessful

我整天都在反对它,并且已经跟踪了我在stackoverflow上找到的所有内容,最后决定提出问题。 (我已经在类似的问题中验证了here和其他一些内容)

这是我的gradle文件:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
        mavenCentral()
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
        classpath 'com.android.tools.build:gradle:2.1.2'
        classpath 'com.google.gms:google-services:3.0.0'
    }
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
    maven { url 'https://maven.fabric.io/public' }
    mavenCentral()
    jcenter()
    flatDir {
        dirs 'libs'
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion '23.0.3'

    defaultConfig {
        applicationId "com.my.app"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 33
        versionName "3.1.0"
        renderscriptTargetApi 19
        renderscriptSupportModeEnabled true
    }
    buildTypes {
        release {
            minifyEnabled true
            shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    applicationVariants.all { variant ->
        variant.outputs.each { output ->
            output.outputFile = new File(
                    output.outputFile.parent,
                    output.outputFile.name.replace(".apk", "-${variant.versionCode}-${variant.versionName}.apk"))
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
    sourceSets { main { assets.srcDirs = ['src/main/assets', 'src/main/assets/fonts'] } }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:recyclerview-v7:23.4.0'
    compile 'com.google.android.gms:play-services-base:9.2.0'
    compile 'com.google.android.gms:play-services-plus:9.2.0'
    compile 'com.google.android.gms:play-services-analytics:9.2.0'
    compile 'com.google.android.gms:play-services-appindexing:9.2.0'
    compile 'com.google.android.gms:play-services-identity:9.2.0'
    compile 'com.google.android.gms:play-services-location:9.2.0'
    compile 'com.google.firebase:firebase-core:9.2.0'
    compile 'com.google.firebase:firebase-messaging:9.2.0'
...
}

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

我的目录结构:

Main Folder
->gradle
->build
->app
--->google-services.json
->custom
--->src
--->build
--->google-services.json
--->all the files pertaining to application

google-services.json都是一样的 json文件也包含SHA1值(在firebase控制台中设置)。

迁移遵循:https://developers.google.com/cloud-messaging/android/android-migrate-fcm

任何帮助都非常感谢,因为我还没有找到解决方案。

修改

添加项目级build.gradle文件:

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

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.2'
        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

0 个答案:

没有答案