I had an error while trying to migrate to FireBase managed push, I tried using class FCMservice as the push app in samples but my app crashes giving this log:
FATAL EXCEPTION: AsyncTask #3
Process: com.galsa.example, PID: 17415
java.lang.RuntimeException: An error occurred while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:318)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:354)
at java.util.concurrent.FutureTask.setException(FutureTask.java:223)
at java.util.concurrent.FutureTask.run(FutureTask.java:242)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)
Caused by: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.galsa.example. Make sure to call FirebaseApp.initializeApp(Context) first.
at com.google.firebase.FirebaseApp.getInstance(Unknown Source)
at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source)
at com.sinch.android.rtc.internal.client.fcm.FcmTask.doInBackground(Unknown Source)
at com.sinch.android.rtc.internal.client.fcm.FcmTask.doInBackground(Unknown Source)
at android.os.AsyncTask$2.call(AsyncTask.java:304)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:243)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:762)
first you need to add this line in your dependencies in your root gradle file:
classpath 'com.google.gms:google-services:3.1.0'
then you have to add this line in dependencies in your project gradle file:
implementation 'com.google.firebase:firebase-messaging:11.6.0'
and also add this line at the end of your project gradle file:
apply plugin: 'com.google.gms.google-services'
then you have to follow the steps in this link to generate google-services.json
file and put it in the root folder of your project.