React-native-onesignal: [Android Pie] Crashed when onReceive fired

Created on 31 Aug 2018  路  9Comments  路  Source: OneSignal/react-native-onesignal

Description:

My App crashed when received background notification. It resulted this error message:

java.lang.NoSuchMethodError: No static method zzc(Landroid/content/Context;)Lcom/google/firebase/iid/zzaa; in class Lcom/google/firebase/iid/zzaa; or its super classes (declaration of 'com.google.firebase.iid.zzaa' appears in base.apk)
    at com.google.firebase.messaging.FirebaseMessagingService.zzd(Unknown Source:29)
    at com.google.firebase.iid.zzg.run(Unknown Source:26)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
    at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source:7)
    at java.lang.Thread.run(Thread.java:764)

You can look my app/build.gradle in this link https://pastebin.com/kq7D6amV

I realized, this error only showed on Android Pie (Google Pixel 1). When I tried on other phone using prior version, it work normally.

Environment

  1. What version of the OneSignal React-Native SDK are you using?
    react-native-onesignal": "^3.2.6
  1. How did you add the SDK to your project (eg. npm)
    npm install react-native-onesignal@latest

  2. Android Version:
    Android Pie 9.0

Steps to Reproduce Issue:

  1. run npm install -- save react-native-onesignal@latest
  2. implement
    OneSignal.addEventListener('received', (notification)=>{console.log(notification)}
  3. Send messages without title, but insert some background data
  4. Crashed

On my app logcat, it still be able to print the log (notification), shortly after that, my app crashed. Sometimes, the crash error messages printed before the log, but sometimes, it printed after the log.

Most helpful comment

I also experienced the same issue. I solved it by upgrading com.google.gms:google-services from 4.0.1 to 4.1.0.

All 9 comments

@abdullahizzuddiin What version of the RN?

@abdullahizzuddiin I cannot reproduce this issue on our own Android 9 devices. Also, I can no longer see your app/build.gradle, have you added our gradle plugin?

If not, please try adding this to the very top of your app/build.gradle and let me know if the issue still occurs:

buildscript {
    repositories {
        maven { url 'https://plugins.gradle.org/m2/'}
    }
    dependencies {
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:[0.11.0, 0.99.99]'
    }
}
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'

repositories {
    jcenter()
    maven { url 'https://maven.google.com' }
}

@abdullahizzuddiin Would you also please post your package.json?

I also experienced the same issue. I solved it by upgrading com.google.gms:google-services from 4.0.1 to 4.1.0.

@abdullahizzuddiin can you post your app/build.gradle and give @anjar10鈥檚 suggestion a shot?

(Assuming you hadn鈥檛 already fixed this issue in the past 8 days, apologies for the delay we鈥檝e been swamped/busy lately)

Closing due to no response, if you're still having this problem please post and I'll be happy to reopen and help investigate

Thank to @anjar10 my problem solved after I implement his suggestion.

Thanks to you all :)

I also experienced the same issue. I solved it by upgrading com.google.gms:google-services from 4.0.1 to 4.1.0.

@anjar10 : Can you please elaborate the fix? Did you change in the build.gradle file? Would you mind pasting your file here?

I just upgrade google service in build.gradle file which located in <PROJECT_ROOT>\build.gradle. Here is my build.gradle file:

...
buildscript {
    repositories {
        jcenter()
        google()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
        classpath 'com.google.gms:google-services:4.1.0'
    }
}
...
Was this page helpful?
0 / 5 - 0 ratings