Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Firebase with qt as service (Android)
QtWS25 Last Chance

Firebase with qt as service (Android)

Scheduled Pinned Locked Moved Solved Mobile and Embedded
7 Posts 4 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Devoo
    wrote on last edited by Devoo
    #1

    Hi,
    I am trying to move firebase listener from main application activity (where works correctly) to background service.
    For some reason service cannot be initialized with firebase.

    Log from ADB logcat:

    Default FirebaseApp is not initialized in this process com.test.example:notification. Make sure to call FirebaseApp.initializeApp(Context) first.
    

    To create service solution I am using QAndroidService.

    void FirebaseListener::initialize()
            {
                if(m_app == nullptr)
                {
                    QAndroidJniObject androidActivity = QtAndroid::androidService();
                    ::firebase::App* appInstance = ::firebase::App::GetInstance();
                    if (appInstance)
                    {
                        qInfo() << "Firebase app instance already exists";
                        m_app = appInstance;
                    }
                    else
                    {
                        qInfo() << "Creating Firebase app instance";
    
    // This code line affects application crash
                        m_app = ::firebase::App::Create(
                                    m_jniEnvironment,
                                    androidActivity.object<jobject>());
                    }
    
                    m_moduleInitializer.Initialize(m_app, nullptr, _initializeMessaging);
                }
            }
    

    Firebase listener is implemented as descriptes here:
    https://medium.com/@shigmas/push-notifications-in-qt-for-ios-and-android-50c2f9a38444

    How to fix it? Any idea?

    raven-worxR 1 Reply Last reply
    0
    • D Devoo

      Hi,
      I am trying to move firebase listener from main application activity (where works correctly) to background service.
      For some reason service cannot be initialized with firebase.

      Log from ADB logcat:

      Default FirebaseApp is not initialized in this process com.test.example:notification. Make sure to call FirebaseApp.initializeApp(Context) first.
      

      To create service solution I am using QAndroidService.

      void FirebaseListener::initialize()
              {
                  if(m_app == nullptr)
                  {
                      QAndroidJniObject androidActivity = QtAndroid::androidService();
                      ::firebase::App* appInstance = ::firebase::App::GetInstance();
                      if (appInstance)
                      {
                          qInfo() << "Firebase app instance already exists";
                          m_app = appInstance;
                      }
                      else
                      {
                          qInfo() << "Creating Firebase app instance";
      
      // This code line affects application crash
                          m_app = ::firebase::App::Create(
                                      m_jniEnvironment,
                                      androidActivity.object<jobject>());
                      }
      
                      m_moduleInitializer.Initialize(m_app, nullptr, _initializeMessaging);
                  }
              }
      

      Firebase listener is implemented as descriptes here:
      https://medium.com/@shigmas/push-notifications-in-qt-for-ios-and-android-50c2f9a38444

      How to fix it? Any idea?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @Devoo said in Firebase with qt as service (Android):

      androidActivity.object<jobject>()

      did you check the return value of androidActivity.object<jobject>()?
      Also logcat should print some lines regarding the crash itself.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      1
      • M Offline
        M Offline
        Montjet
        wrote on last edited by Montjet
        #3

        @raven-worx said in Firebase with qt as service (Android):

        @Devoo said in Firebase with qt as service (Android):

        androidActivity.object<jobject>()

        did you check the return value of androidActivity.object<jobject>()?

        Yes, I checked it - previously I also had a different Java class that required the service context and worked well :\

        Also logcat should print some lines regarding the crash itself.

        I will check it on Monday.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          Devoo
          wrote on last edited by Devoo
          #4

          Full log (only notificationService solution):

          02-11 07:52:13.188  4746  4767 I Example: ..\Example\sources\notificationService\FirebaseListener.cpp:31 (void Example::NotificationService::FirebaseListener::initialize()): aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa  0x22d2  :  0x0  :  0x22f2
          02-11 07:52:13.188  4746  4767 I Example: ..\Example\sources\notificationService\FirebaseListener.cpp:41 (void Example::NotificationService::FirebaseListener::initialize()): Creating Firebase app instance
          02-11 07:52:13.207  4746  4767 I firebase: Firebase App initializing app com.test.example (default 1).
          02-11 07:52:13.207  4746  4767 I firebase: Firebase App initializing app com.test.example (default 1).
          02-11 07:52:13.210  4746  4767 W System.err: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.test.example:notification. Make sure to call FirebaseApp.initializeApp(Context) first.
          02-11 07:52:13.210  4746  4767 W System.err: 	at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@16.0.2:240)
          02-11 07:52:13.210  4746  4767 W System.err: 	at org.qtproject.qt5.android.QtNative.startQtApplication(Native Method)
          02-11 07:52:13.210  4746  4767 W System.err: 	at org.qtproject.qt5.android.QtNative$6.run(QtNative.java:359)
          02-11 07:52:13.210  4746  4767 W System.err: 	at org.qtproject.qt5.android.QtThread$1.run(QtThread.java:61)
          02-11 07:52:13.210  4746  4767 W System.err: 	at java.lang.Thread.run(Thread.java:784)
          02-11 07:52:13.210  4746  4767 E firebase: new_app
          02-11 07:52:13.210  4746  4767 F firebase: Failed to initialize the default Firebase App.
          --------- beginning of crash
          02-11 07:52:13.210  4746  4767 F libc    : Fatal signal 6 (SIGABRT), code -6 in tid 4767 (qtMainLoopThrea)
          02-11 07:52:13.227  4770  4770 W crash_dump32: type=1400 audit(0.0:5077): avc: denied { search } for name="com.test.example" dev="mmcblk0p59" ino=7584 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
          02-11 07:52:13.227  4770  4770 I chatty  : uid=10149(u0_a149) crash_dump32 identical 4 lines
          02-11 07:52:13.227  4770  4770 W crash_dump32: type=1400 audit(0.0:5082): avc: denied { search } for name="com.test.example" dev="mmcblk0p59" ino=7584 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
          02-11 07:52:13.235  4770  4770 W crash_dump32: type=1400 audit(0.0:5083): avc: denied { search } for name="files" dev="mmcblk0p59" ino=17001 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
          02-11 07:52:13.243  4770  4770 I crash_dump32: obtaining output fd from tombstoned
          02-11 07:52:13.244   779   779 I /system/bin/tombstoned: received crash request for pid 4746
          02-11 07:52:13.246  4770  4770 I crash_dump32: performing dump of process 4746 (target tid = 4767)
          02-11 07:52:13.247  4770  4770 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
          02-11 07:52:13.247  4770  4770 F DEBUG   : Build fingerprint: 'HUAWEI/CMR-AL09/HWCMR09:8.0.0/HUAWEICMR-AL09/195(C432):user/release-keys'
          02-11 07:52:13.247  4770  4770 F DEBUG   : Revision: '0'
          02-11 07:52:13.247  4770  4770 F DEBUG   : ABI: 'arm'
          02-11 07:52:13.247  4770  4770 F DEBUG   : pid: 4746, tid: 4767, name: qtMainLoopThrea  >>> com.test.example:notification <<<
          02-11 07:52:13.247  4770  4770 F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
          02-11 07:52:13.250  4770  4770 F DEBUG   : Abort message: 'Failed to initialize the default Firebase App.'
          02-11 07:52:13.250  4770  4770 F DEBUG   :     r0 00000000  r1 0000129f  r2 00000006  r3 00000008
          02-11 07:52:13.250  4770  4770 F DEBUG   :     r4 0000128a  r5 0000129f  r6 c4c817e0  r7 0000010c
          02-11 07:52:13.250  4770  4770 F DEBUG   :     r8 c4c8183c  r9 c4c818ec  sl e70b3290  fp da9944f0
          02-11 07:52:13.250  4770  4770 F DEBUG   :     ip 00000000  sp c4c817d0  lr e7f23477  pc e7f543ac  cpsr 200d0010
          02-11 07:52:13.247  4770  4770 W crash_dump32: type=1400 audit(0.0:5084): avc: denied { search } for name="com.test.example" dev="mmcblk0p59" ino=7584 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
          02-11 07:52:13.252  4770  4770 F DEBUG   : 
          02-11 07:52:13.252  4770  4770 F DEBUG   : backtrace:
          02-11 07:52:13.252  4770  4770 F DEBUG   :     #00 pc 0004b3ac  /system/lib/libc.so (tgkill+12)
          02-11 07:52:13.252  4770  4770 F DEBUG   :     #01 pc 0001a473  /system/lib/libc.so (abort+54)
          02-11 07:52:13.252  4770  4770 F DEBUG   :     #02 pc 0003023d  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so
          02-11 07:52:13.252  4770  4770 F DEBUG   :     #03 pc 00030377  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so
          02-11 07:52:13.252  4770  4770 F DEBUG   :     #04 pc 000304f1  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so (_ZN8firebase9LogAssertEPKcz+36)
          02-11 07:52:13.252  4770  4770 F DEBUG   :     #05 pc 00043091  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so (_ZN8firebase3App6CreateERKNS_10AppOptionsEPKcP7_JNIEnvP8_jobject+1148)
          02-11 07:52:13.252  4770  4770 F DEBUG   :     #06 pc 00025714  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so (_ZN8firebase3App6CreateEP7_JNIEnvP8_jobject+72)
          02-11 07:52:13.252  4770  4770 F DEBUG   :     #07 pc 000253a0  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so (_ZN9Example19NotificationService16FirebaseListener10initializeEv+644)
          02-11 07:52:13.252  4770  4770 F DEBUG   :     #08 pc 00024b28  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so (_ZN9Example19NotificationService29NotificationServiceController10initializeEv+28)
          02-11 07:52:13.252  4770  4770 F DEBUG   :     #09 pc 000240fc  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so (main+580)
          02-11 07:52:13.252  4770  4770 F DEBUG   :     #10 pc 000198e5  /data/data/com.test.example/qt-reserved-files/plugins/platforms/android/libqtforandroid.so
          02-11 07:52:13.501   779   779 E /system/bin/tombstoned: Tombstone written to: /data/tombstones//tombstone_04
          02-11 07:52:13.503  1208  1250 W ActivityManager: Skipping native crash dialog of ProcessRecord{a47de3d 4746:com.test.example:notification/u0a149}
          02-11 07:52:13.551  1208  1208 W Binder:1208_16: type=1400 audit(0.0:5085): avc: granted { read } for path="/data/system/dropbox/data_app_native_crash@1549867933509.txt" dev="mmcblk0p59" ino=12496 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:system_data_file:s0 tclass=file
          02-11 07:52:13.551  1208  1208 W Binder:1208_16: type=1400 audit(0.0:5086): avc: granted { read } for path="/data/system/dropbox/SYSTEM_TOMBSTONE@1549867933540.txt.gz" dev="mmcblk0p59" ino=7867 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:system_data_file:s0 tclass=file
          02-11 07:52:13.566  2749  4774 D WorkSource: Insert in WorkSource{} @ 0 uid 10020 name com.google.android.gms
          02-11 07:52:13.567  1208  1223 I ActivityManager: Process com.test.example:notification (pid 4746) has died: fore SVC 
          02-11 07:52:13.567  1208  1223 D ActivityManager: cleanUpApplicationRecord app: ProcessRecord{a47de3d 4746:com.test.example:notification/u0a149}, app.bad: false, restarting: false, allowRestart: true
          02-11 07:52:13.567  1208  1223 W ActivityManager: Scheduling restart of crashed service com.test.example/.NotificationServiceActivity in 1098ms
          
          

          where "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa " is new code line:

          qInfo() << "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa " << QtAndroid::androidService().object() << " : "
                                      << QtAndroid::androidActivity().object() << " : "
                                          << QtAndroid::androidContext().object();
          

          btw.
          I am using replicas to communicate with main application.

          #edit
          Version of firebase modules (build.gradle):

              compile 'com.android.support:support-v4:27.0.0'
              compile 'com.google.firebase:firebase-core:16.0.6'
              compile 'com.google.firebase:firebase-auth:16.1.0'
              compile 'com.google.firebase:firebase-messaging:17.3.4'
              compile 'com.google.firebase.messaging.cpp:firebase_messaging_cpp@aar'
              compile 'com.google.android.gms:play-services-base:8.4.0'
          
          raven-worxR 1 Reply Last reply
          0
          • D Devoo

            Full log (only notificationService solution):

            02-11 07:52:13.188  4746  4767 I Example: ..\Example\sources\notificationService\FirebaseListener.cpp:31 (void Example::NotificationService::FirebaseListener::initialize()): aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa  0x22d2  :  0x0  :  0x22f2
            02-11 07:52:13.188  4746  4767 I Example: ..\Example\sources\notificationService\FirebaseListener.cpp:41 (void Example::NotificationService::FirebaseListener::initialize()): Creating Firebase app instance
            02-11 07:52:13.207  4746  4767 I firebase: Firebase App initializing app com.test.example (default 1).
            02-11 07:52:13.207  4746  4767 I firebase: Firebase App initializing app com.test.example (default 1).
            02-11 07:52:13.210  4746  4767 W System.err: java.lang.IllegalStateException: Default FirebaseApp is not initialized in this process com.test.example:notification. Make sure to call FirebaseApp.initializeApp(Context) first.
            02-11 07:52:13.210  4746  4767 W System.err: 	at com.google.firebase.FirebaseApp.getInstance(com.google.firebase:firebase-common@@16.0.2:240)
            02-11 07:52:13.210  4746  4767 W System.err: 	at org.qtproject.qt5.android.QtNative.startQtApplication(Native Method)
            02-11 07:52:13.210  4746  4767 W System.err: 	at org.qtproject.qt5.android.QtNative$6.run(QtNative.java:359)
            02-11 07:52:13.210  4746  4767 W System.err: 	at org.qtproject.qt5.android.QtThread$1.run(QtThread.java:61)
            02-11 07:52:13.210  4746  4767 W System.err: 	at java.lang.Thread.run(Thread.java:784)
            02-11 07:52:13.210  4746  4767 E firebase: new_app
            02-11 07:52:13.210  4746  4767 F firebase: Failed to initialize the default Firebase App.
            --------- beginning of crash
            02-11 07:52:13.210  4746  4767 F libc    : Fatal signal 6 (SIGABRT), code -6 in tid 4767 (qtMainLoopThrea)
            02-11 07:52:13.227  4770  4770 W crash_dump32: type=1400 audit(0.0:5077): avc: denied { search } for name="com.test.example" dev="mmcblk0p59" ino=7584 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
            02-11 07:52:13.227  4770  4770 I chatty  : uid=10149(u0_a149) crash_dump32 identical 4 lines
            02-11 07:52:13.227  4770  4770 W crash_dump32: type=1400 audit(0.0:5082): avc: denied { search } for name="com.test.example" dev="mmcblk0p59" ino=7584 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
            02-11 07:52:13.235  4770  4770 W crash_dump32: type=1400 audit(0.0:5083): avc: denied { search } for name="files" dev="mmcblk0p59" ino=17001 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
            02-11 07:52:13.243  4770  4770 I crash_dump32: obtaining output fd from tombstoned
            02-11 07:52:13.244   779   779 I /system/bin/tombstoned: received crash request for pid 4746
            02-11 07:52:13.246  4770  4770 I crash_dump32: performing dump of process 4746 (target tid = 4767)
            02-11 07:52:13.247  4770  4770 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
            02-11 07:52:13.247  4770  4770 F DEBUG   : Build fingerprint: 'HUAWEI/CMR-AL09/HWCMR09:8.0.0/HUAWEICMR-AL09/195(C432):user/release-keys'
            02-11 07:52:13.247  4770  4770 F DEBUG   : Revision: '0'
            02-11 07:52:13.247  4770  4770 F DEBUG   : ABI: 'arm'
            02-11 07:52:13.247  4770  4770 F DEBUG   : pid: 4746, tid: 4767, name: qtMainLoopThrea  >>> com.test.example:notification <<<
            02-11 07:52:13.247  4770  4770 F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
            02-11 07:52:13.250  4770  4770 F DEBUG   : Abort message: 'Failed to initialize the default Firebase App.'
            02-11 07:52:13.250  4770  4770 F DEBUG   :     r0 00000000  r1 0000129f  r2 00000006  r3 00000008
            02-11 07:52:13.250  4770  4770 F DEBUG   :     r4 0000128a  r5 0000129f  r6 c4c817e0  r7 0000010c
            02-11 07:52:13.250  4770  4770 F DEBUG   :     r8 c4c8183c  r9 c4c818ec  sl e70b3290  fp da9944f0
            02-11 07:52:13.250  4770  4770 F DEBUG   :     ip 00000000  sp c4c817d0  lr e7f23477  pc e7f543ac  cpsr 200d0010
            02-11 07:52:13.247  4770  4770 W crash_dump32: type=1400 audit(0.0:5084): avc: denied { search } for name="com.test.example" dev="mmcblk0p59" ino=7584 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0
            02-11 07:52:13.252  4770  4770 F DEBUG   : 
            02-11 07:52:13.252  4770  4770 F DEBUG   : backtrace:
            02-11 07:52:13.252  4770  4770 F DEBUG   :     #00 pc 0004b3ac  /system/lib/libc.so (tgkill+12)
            02-11 07:52:13.252  4770  4770 F DEBUG   :     #01 pc 0001a473  /system/lib/libc.so (abort+54)
            02-11 07:52:13.252  4770  4770 F DEBUG   :     #02 pc 0003023d  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so
            02-11 07:52:13.252  4770  4770 F DEBUG   :     #03 pc 00030377  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so
            02-11 07:52:13.252  4770  4770 F DEBUG   :     #04 pc 000304f1  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so (_ZN8firebase9LogAssertEPKcz+36)
            02-11 07:52:13.252  4770  4770 F DEBUG   :     #05 pc 00043091  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so (_ZN8firebase3App6CreateERKNS_10AppOptionsEPKcP7_JNIEnvP8_jobject+1148)
            02-11 07:52:13.252  4770  4770 F DEBUG   :     #06 pc 00025714  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so (_ZN8firebase3App6CreateEP7_JNIEnvP8_jobject+72)
            02-11 07:52:13.252  4770  4770 F DEBUG   :     #07 pc 000253a0  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so (_ZN9Example19NotificationService16FirebaseListener10initializeEv+644)
            02-11 07:52:13.252  4770  4770 F DEBUG   :     #08 pc 00024b28  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so (_ZN9Example19NotificationService29NotificationServiceController10initializeEv+28)
            02-11 07:52:13.252  4770  4770 F DEBUG   :     #09 pc 000240fc  /data/app/com.test.example-M1PkScmluyEvK7OXnXfxow==/lib/arm/libNotificationService.so (main+580)
            02-11 07:52:13.252  4770  4770 F DEBUG   :     #10 pc 000198e5  /data/data/com.test.example/qt-reserved-files/plugins/platforms/android/libqtforandroid.so
            02-11 07:52:13.501   779   779 E /system/bin/tombstoned: Tombstone written to: /data/tombstones//tombstone_04
            02-11 07:52:13.503  1208  1250 W ActivityManager: Skipping native crash dialog of ProcessRecord{a47de3d 4746:com.test.example:notification/u0a149}
            02-11 07:52:13.551  1208  1208 W Binder:1208_16: type=1400 audit(0.0:5085): avc: granted { read } for path="/data/system/dropbox/data_app_native_crash@1549867933509.txt" dev="mmcblk0p59" ino=12496 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:system_data_file:s0 tclass=file
            02-11 07:52:13.551  1208  1208 W Binder:1208_16: type=1400 audit(0.0:5086): avc: granted { read } for path="/data/system/dropbox/SYSTEM_TOMBSTONE@1549867933540.txt.gz" dev="mmcblk0p59" ino=7867 scontext=u:r:priv_app:s0:c512,c768 tcontext=u:object_r:system_data_file:s0 tclass=file
            02-11 07:52:13.566  2749  4774 D WorkSource: Insert in WorkSource{} @ 0 uid 10020 name com.google.android.gms
            02-11 07:52:13.567  1208  1223 I ActivityManager: Process com.test.example:notification (pid 4746) has died: fore SVC 
            02-11 07:52:13.567  1208  1223 D ActivityManager: cleanUpApplicationRecord app: ProcessRecord{a47de3d 4746:com.test.example:notification/u0a149}, app.bad: false, restarting: false, allowRestart: true
            02-11 07:52:13.567  1208  1223 W ActivityManager: Scheduling restart of crashed service com.test.example/.NotificationServiceActivity in 1098ms
            
            

            where "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa " is new code line:

            qInfo() << "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa " << QtAndroid::androidService().object() << " : "
                                        << QtAndroid::androidActivity().object() << " : "
                                            << QtAndroid::androidContext().object();
            

            btw.
            I am using replicas to communicate with main application.

            #edit
            Version of firebase modules (build.gradle):

                compile 'com.android.support:support-v4:27.0.0'
                compile 'com.google.firebase:firebase-core:16.0.6'
                compile 'com.google.firebase:firebase-auth:16.1.0'
                compile 'com.google.firebase:firebase-messaging:17.3.4'
                compile 'com.google.firebase.messaging.cpp:firebase_messaging_cpp@aar'
                compile 'com.google.android.gms:play-services-base:8.4.0'
            
            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by raven-worx
            #5

            @Devoo
            so the crash comes from the firebase9LogAssert call. I assume this is the error message you already mentioned.
            It may simply be that your C++ call comes too late in the call hierarchy. Sometimes some calls are only possible from the Context itself (java), since Qt enters the whole application lifecycle at a later point. Which is very likely since you are saying that it works from java side.
            But hard to say, when is FirebaseListener::initialize() called and what does ::firebase::App::GetInstance() and m_moduleInitializer.Initialize() do exactly?

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            2
            • D Offline
              D Offline
              Devoo
              wrote on last edited by
              #6

              I have tried to implement the same solution using only java language and it works correctly.
              I have one small problem now, but I will create new topic for this.
              Thank You for help.

              1 Reply Last reply
              0
              • RaadR Offline
                RaadR Offline
                Raad
                wrote on last edited by
                #7

                try this:

                in your header

                QAndroidJniEnvironment *_jniEnv;
                   ::firebase::App* _app;
                   ::firebase::ModuleInitializer _initializer;
                   QAndroidJniObject _jniObj;
                

                in your .cpp file:

                _jniEnv = new QAndroidJniEnvironment();
                  QAndroidJniObject jniObject = QtAndroid::androidActivity();
                  ::firebase::App *instance = ::firebase::App::GetInstance();
                
                  if (instance) {
                      _app = instance;
                  }
                else {
                      jniObject = QtAndroid::androidActivity();
                      _app = ::firebase::App::Create(*_jniEnv, jniObject.object<jobject>());
                  }
                }
                
                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved