GCM Error - googleCloudMessaging.register

蓝咒 提交于 2019-12-04 00:25:30

Google has updated on their release note that this issue is fixed, you just have to update the version to 9.0.2

Here is the release note: https://developers.google.com/android/guides/releases

The issue you are experiencing is due to an incompatibility between
play-services / firebase sdk v9.0.0 and com.android.support:appcompat-v7 >= 24
It's possible that you are not depending directly from appcompat-v7 >= 24 but some other dependencies are configured to use the most updated appcompat available.

To fix this issue we just released play-services / firebase sdk version 9.0.1
This minor release should fix the incompatibility with appcompat-v7 !

Arpit Patel

I also facing same error.

SOLUTION

Just paste this in your gradle file

configurations.all {
        resolutionStrategy {
            force 'com.android.support:design:23.4.0'
            force 'com.android.support:support-v4:23.4.0'
            force 'com.android.support:appcompat-v7:23.4.0'
        }
    }

This issue is that you have dependencies that include old versions of the support library. CHECK THIS LINK

Here is my gradle file check this

gradle

    apply plugin: 'com.android.application'

android {
    signingConfigs {
        config {
            keyAlias 'hwindi'
            keyPassword '123456'
            storeFile file('D:/Company Projects/Hwindi/Project 2/Play_KeyStore/HwindiKeyStore.jks')
            storePassword '123456'
        }
    }
    compileSdkVersion 23
    buildToolsVersion "23.0.2"
    defaultConfig {
        applicationId "com.hwindiapp.passenger"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 7
        versionName "1.6"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'lib/arm64-v8a/libcardioDecider.so'
        exclude 'lib/arm64-v8a/libcardioRecognizer.so'
        exclude 'lib/arm64-v8a/libcardioRecognizer_tegra2.so'
        exclude 'lib/arm64-v8a/libopencv_core.so'
        exclude 'lib/arm64-v8a/libopencv_imgproc.so'
        exclude 'lib/armeabi/libcardioDecider.so'
        exclude 'lib/armeabi-v7a/libcardioDecider.so'
        exclude 'lib/armeabi-v7a/libcardioRecognizer.so'
        exclude 'lib/armeabi-v7a/libcardioRecognizer_tegra2.so'
        exclude 'lib/armeabi-v7a/libopencv_core.so'
        exclude 'lib/armeabi-v7a/libopencv_imgproc.so'
        exclude 'lib/mips/libcardioDecider.so'
        exclude 'lib/x86/libcardioDecider.so'
        exclude 'lib/x86/libcardioRecognizer.so'
        exclude 'lib/x86/libcardioRecognizer_tegra2.so'
        exclude 'lib/x86/libopencv_core.so'
        exclude 'lib/x86/libopencv_imgproc.so'
        exclude 'lib/x86_64/libcardioDecider.so'
        exclude 'lib/x86_64/libcardioRecognizer.so'
        exclude 'lib/x86_64/libcardioRecognizer_tegra2.so'
        exclude 'lib/x86_64/libopencv_core.so'
        exclude 'lib/x86_64/libopencv_imgproc.so'
    }
    configurations.all {
        resolutionStrategy {
            force 'com.android.support:design:23.4.0'
            force 'com.android.support:support-v4:23.4.0'
            force 'com.android.support:appcompat-v7:23.4.0'
        }
    }
}
repositories {
    mavenCentral()
    maven { url "https://jitpack.io" }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:cardview-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1+'
    compile 'com.google.android.gms:play-services-gcm:9.0.0'
    compile 'com.google.android.gms:play-services-location:9.0.0'
    compile 'com.google.android.gms:play-services-maps:9.0.0'
    compile 'com.google.android.gms:play-services-plus:9.0.0'
    compile 'com.facebook.android:facebook-android-sdk:4+'
    compile 'com.paypal.sdk:paypal-android-sdk:2.13.3'
    compile 'com.wdullaer:materialdatetimepicker:2.2.0'
    compile 'com.mukesh:permissions:1.0.3'
}
Teyam

As far as I have read, java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] doesn't exist error, which you encountered after migrating a GCM Client App for Android to Firebase Cloud Messaging, were also encountered by many developers after adding the dependency for Crash Reporting to project-level build.gradle file:

compile 'com.google.firebase:firebase-crash:9.0.0'

So, if you happen to use Firebase Crash Reporting, you must ensure that crash reporting is multi-process safe. Otherwise, it may cause concurrency issues as stated in Report Crashes - Known Issues.

One probable solution that I found is to set Android context and enable Offline Persistence, wherein you enable it via the FirebaseDatabase object in your MainActivity:

FirebaseDatabase.getInstance().setPersistenceEnabled(true);

Sample solution in MainActivity.java:

@Override
public void onCreate() {
  super.onCreate();
  if (!FirebaseApp.getApps(this).isEmpty()) {
    FirebaseDatabase.getInstance().setPersistenceEnabled(true);
  }
}

This SO post - java.lang.IllegalStateException: FirebaseApp with name [DEFAULT] helped with my searches. I hope that will help you too.

Gent Berani

Finally this problem is solved on v9.0.2. Just update Google Play Service library.

compile 'com.google.android.gms:play-services:9.0.2'

After updating, another error can occur: finished with non-zero exit value 2 Solution for this one is here: Java finished with non-zero exit value 2 - Android Gradle

Solved issue by using below code. Just updated

compileSdkVersion 24
buildToolsVersion "24.0.1"
.
.
.
dependencies
{
compile 'com.android.support:recyclerview-v7:24.1.1'
compile "com.google.android.gms:play-services-gcm:9.4.0"
}

This solved my GCM error.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!