aerogear / aerogear-android-sdk

AeroGear Services Android SDK
Apache License 2.0
8 stars 31 forks source link

Error initializing Firebase #295

Open proncerof opened 6 years ago

proncerof commented 6 years ago

Expected Behavior

Be able to receive push notification in my Android app.

Actual Behavior

When I finish the instructions in https://aerogear.org/docs/unifiedpush/aerogear-push-android/guides/#android-app I get this error.

09-18 15:10:05.247 15686-15717/com.example.proncero.testaerogear E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
09-18 15:10:05.249 15686-15717/com.example.proncero.testaerogear E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
09-18 15:10:05.271 15686-15686/com.example.proncero.testaerogear E/MainActivity: Default FirebaseApp is not initialized in this process com.example.proncero.testaerogear. Make sure to call FirebaseApp.initializeApp(Context) first.
    java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.example.proncero.testaerogear. Make sure to call FirebaseApp.initializeApp(Context) first.
        at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@16.0.1:219)
        at com.google.firebase.iid.FirebaseInstanceId.getInstance(Unknown Source:0)
        at org.jboss.aerogear.android.unifiedpush.fcm.AeroGearFCMPushRegistrar$2.get(AeroGearFCMPushRegistrar.java:100)
        at org.jboss.aerogear.android.unifiedpush.fcm.AeroGearFCMPushRegistrar$2.get(AeroGearFCMPushRegistrar.java:96)
        at org.jboss.aerogear.android.unifiedpush.fcm.AeroGearFCMPushRegistrar$4.doInBackground(AeroGearFCMPushRegistrar.java:145)
        at org.jboss.aerogear.android.unifiedpush.fcm.AeroGearFCMPushRegistrar$4.doInBackground(AeroGearFCMPushRegistrar.java:135)
        at android.os.AsyncTask$2.call(AsyncTask.java:333)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)

After looking for the error I found that I should add the following lines: build.gradle (App)

dependencies {
         ...
         implementation 'com.google.firebase:firebase-core:16.0.3'
         ...
}
...
apply plugin: 'com.google.gms.google-services'

build.gradle (Project)

dependecies {
        ...
        classpath 'com.google.gms:google-services:4.0.1'
        ...
}

But I get this new error

09-18 15:07:24.493 14229-14259/com.example.proncero.testaerogear E/eglCodecCommon: glUtilsParamSize: unknow param 0x000082da
    glUtilsParamSize: unknow param 0x000082da
09-18 15:07:24.557 14229-14256/com.example.proncero.testaerogear E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #1
    Process: com.example.proncero.testaerogear, PID: 14229
    java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:353)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
        at java.util.concurrent.FutureTask.run(FutureTask.java:271)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.NoSuchMethodError: No virtual method zztq(Ljava/lang/String;)V in class Lcom/google/firebase/iid/FirebaseInstanceId; or its super classes (declaration of 'com.google.firebase.iid.FirebaseInstanceId' appears in /data/app/com.example.proncero.testaerogear-3AgyYDeNhA6CaXIiISo7-w==/split_lib_dependencies_apk.apk)
        at com.google.firebase.messaging.FirebaseMessaging.subscribeToTopic(Unknown Source:72)
        at org.jboss.aerogear.android.unifiedpush.fcm.AeroGearFCMPushRegistrar$4.doInBackground(AeroGearFCMPushRegistrar.java:193)
        at org.jboss.aerogear.android.unifiedpush.fcm.AeroGearFCMPushRegistrar$4.doInBackground(AeroGearFCMPushRegistrar.java:135)
        at android.os.AsyncTask$2.call(AsyncTask.java:333)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 
        at java.lang.Thread.run(Thread.java:764)

Specifications

danielpassos commented 5 years ago

Hey @ronce96 Are you still having this problem? Sorry for the too late reply, for some reason the GH did not me notified about that.

pcsantana commented 4 years ago

Hi! @ronce96 did you solve id? I'm facing the same exception, after I upgrade firebase versions and migrate to androidx lib!

java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:353)
        at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
        at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
        at java.util.concurrent.FutureTask.run(FutureTask.java:271)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.NoSuchMethodError: No virtual method subscribeToTopic(Ljava/lang/String;)V in class Lcom/google/firebase/messaging/FirebaseMessaging; or its super classes (declaration of 'com.google.firebase.messaging.FirebaseMessaging' appears in /data/app/<app_id>-YWqXXs5LyCG-3skvD41NvQ==/base.apk:classes4.dex)
        at org.jboss.aerogear.android.unifiedpush.fcm.AeroGearFCMPushRegistrar$4.doInBackground(AeroGearFCMPushRegistrar.java:193)
        at org.jboss.aerogear.android.unifiedpush.fcm.AeroGearFCMPushRegistrar$4.doInBackground(AeroGearFCMPushRegistrar.java:135)
        at android.os.AsyncTask$2.call(AsyncTask.java:333)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245) 
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) 
        at java.lang.Thread.run(Thread.java:764) 
danielpassos commented 4 years ago

@pcsantana Maybe the problem is because the AeroGear SDK is not using AndroidX yet. Do you have the same problem only updating the Firebase dependency?

pcsantana commented 4 years ago

Yes, since the com.google.firebase:firebase-messaging:17.+, without androidx.

danielpassos commented 4 years ago

@pcsantana I will try to take a look at this at the weekend.

pcsantana commented 4 years ago

Maybe I found the reason. As the release notes says in Cloud Messaging session:

The methods subscribeToTopic() and unsubscribeFromTopic() on FirebaseMessaging now return a Task that can be used to see when the request has completed.

Before, was just a sync method called in AeroGearFCMPushRegistrar class.

pcsantana commented 4 years ago

Well... maybe you can help me @danielpassos ! Actually, I am using the aerogear-cordova-push.

Looking for the dependencies, I found that the aerogear-android-push dependence is too old. So, I tried to update to the latest one, and the bug I reported before was gone, no errors when register! But now I have another problem. When I send a push notification, throws the following error:

java.lang.RuntimeException: Unable to instantiate service org.jboss.aerogear.android.unifiedpush.fcm.AeroGearFCMMessageReceiver: java.lang.ClassNotFoundException: Didn't find class "org.jboss.aerogear.android.unifiedpush.fcm.AeroGearFCMMessageReceiver" on path: DexPathList[[zip file "/data/app/<package>-2/base.apk"],nativeLibraryDirectories=[/data/app/<package>-2/lib/arm, /data/app/<package>-2/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3168)
        at android.app.ActivityThread.-wrap5(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1563)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6123)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "org.jboss.aerogear.android.unifiedpush.fcm.AeroGearFCMMessageReceiver" on path: DexPathList[[zip file "/data/app/<package>-2/base.apk"],nativeLibraryDirectories=[/data/app/<package>-2/lib/arm, /data/app/<package>-2/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3165)
        at android.app.ActivityThread.-wrap5(ActivityThread.java) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1563) 
        at android.os.Handler.dispatchMessage(Handler.java:102) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6123) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757) 

Any advice? Should I open an issue in aerogear-cordova-push repo?

Thanks in advance!