evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 682 forks source link

App crashing only on Android #965

Closed 404sand808s closed 6 years ago

404sand808s commented 6 years ago

Before openning an issue

  1. Reproduce it with the example project in this repo.
  2. If you can't receive iOS notification, make sure you can receive notification using quickstart-ios project provided by Firebase team

When openning an issue, please include following information for better support

  1. What version of RN and react-native-fcm are you running? RN = 0.54.0, react-native-fcm: latest version (15.0.2)
  2. What device are you using? (e.g iOS9 emulator, Android 6 device)? Pixel 2 API 27
  3. Is your app running in foreground, background or not running? foreground

Hi Evollu,

I'm having a new issue with the component that crashes the Android app. The fatal error displayed on Logcat when this occurs is:

06-05 18:49:14.678 5460-5460/airix.mobile I/zygote: Rejecting re-init on previously-failed class java.lang.Class: java.lang.IllegalAccessError: Class com.google.android.gms.internal.zzbfm extended by class com.google.firebase.messaging.RemoteMessage is inaccessible (declaration of 'com.google.firebase.messaging.RemoteMessage' appears in /data/app/airix.mobile-cCi2-cSxqp3WdSwbOUicpg==/split_lib_dependencies_apk.apk)

I've checked and all the imports seem to be as suggested by you on your readme. Would you have any ideas or any clues? I'm not finding similar errors online anywhere.

Thanks very much.

404sand808s commented 6 years ago

Sorry, this is actually my bad. It was related to not importing a non-deprecated version of firebase cloud messaging. Very confusing stuff.

jamesjara commented 6 years ago

Could you paste the change please... because yes this android versioning change are really confusing , thanks @404sand808s

ruk91 commented 6 years ago

@404sand808s, Can you mention the correct imports?

jamesjara commented 6 years ago

4 days reading gradle, updating dependencies like a crazy, my solution if it works for anybody there @ruk91 android/build.gradle

buildscript { 
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.1'
        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
    }

android/app/build.gradle

dependencies { 
    // ....

    // Push notifications FCM
    compile project(':react-native-fcm')
    // Firebase dependencies <HERE>
    implementation "com.google.android.gms:play-services-base:15.0.1"
    implementation "com.google.firebase:firebase-core:15.0.2"
    implementation "com.google.firebase:firebase-messaging:15.0.2"

    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "com.android.support:appcompat-v7:26.0.1"
    compile ('com.facebook.react:react-native:0.46.4') { force = true } // super hack! From node_modules
}
ruk91 commented 6 years ago

@jamesjara, Thanks so much. It's my 3rd day. Thanks again!!!