Emre D.
Emre D.

Reputation: 579

React Native - App crashes while launching after implementing HMSCore

I tried to run our app on Android Emulator but it crashes without showing any error message. It works fine on iOS and HarmonyOS devices. It was working before. I did not change anything but it started stopping app while launching. I get this error messages on Android Studio.

 2021-06-08 12:49:25.488 5944-5944/com.xxx E/HAInstanceManager: createInstance error
2021-06-08 12:49:25.590 5944-5980/com.xxx E/HMSSDK_HMSPackageManager: Failed to find HMS apk
2021-06-08 12:49:25.746 5944-5980/com.xxx E/HMSSDK_HMSPackageManager: Failed to find HMS apk
2021-06-08 12:49:25.842 5944-5980/com.xxx E/HMSSDK_HMSPackageManager: Failed to find HMS apk
2021-06-08 12:49:25.915 5944-5984/com.xxx E/HMSSDK_HMSPackageManager: Failed to find HMS apk
2021-06-08 12:49:25.933 5944-5984/com.xxx E/HMSSDK_HMSPackageManager: Failed to find HMS apk
2021-06-08 12:49:25.940 5944-5984/com.xxx E/HMSSDK_HMSPackageManager: Failed to find HMS apk
2021-06-08 12:49:25.946 5944-5984/com.xxx E/HMSSDK_SystemUtils: isSystemApp Exception: android.content.pm.PackageManager$NameNotFoundException: com.huawei.appmarket
2021-06-08 12:49:25.968 5944-5944/com.xxx E/SoLoader: couldn't find DSO to load: libjscexecutor.so caused by: dlopen failed: library "libjsc.so" not found result: 0
2021-06-08 12:49:25.972 5944-5984/com.xxx E/HMSSDK_HmsInstanceId: TokenTask failed, ErrorCode: 907135003
2021-06-08 12:49:25.974 5944-5984/com.xxx E/HMSSDK_HMSPackageManager: Failed to find HMS apk
2021-06-08 12:49:26.660 5944-5980/com.xxx E/HMSSDK_HMSPackageManager: Failed to find HMS apk
2021-06-08 12:49:26.661 5944-5980/com.xxx E/HMSSDK_AutoInit: Push init failed
2021-06-08 12:49:27.189 5944-5944/com.xxx E/HMSSDK_HMSPackageManager: Failed to find HMS apk
2021-06-08 12:49:27.314 5944-5944/com.xxx E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.xxx, PID: 5944
    java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.content.Context.getApplicationContext()' on a null object reference
        at com.huawei.hms.rn.push.logger.HMSLogger.getInstance(HMSLogger.java:100)
        at com.huawei.hms.rn.push.remote.HmsPushMessageService.onTokenError(HmsPushMessageService.java:107)
        at com.huawei.hms.push.HmsMessageService.a(HmsMessageService.java:34)
        at com.huawei.hms.push.HmsMessageService.a(HmsMessageService.java:29)
        at com.huawei.hms.push.HmsMessageService.handleIntentMessage(HmsMessageService.java:7)
        at com.huawei.hms.push.HmsMessageService$a.handleMessage(HmsMessageService.java:7)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Is there anyone who faced this issue before? How can I fix this problem?

Upvotes: 2

Views: 1065

Answers (3)

Ghost
Ghost

Reputation: 5019

You might want to disable Huawei Push Kit Automatic Initialization by using HmsPushMessaging.setAutoInitEnabled method.

import { HmsPushMessaging } from "@hmscore/react-native-hms-push";

HmsPushMessaging.setAutoInitEnabled(false)
  .then((result) => {
    this.log("setAutoInitEnabled", result);
  })
  .catch((err) => {
    alert("[setAutoInitEnabled] Error/Exception: " + JSON.stringify(err));
  });

Upvotes: 1

zhangxaochen
zhangxaochen

Reputation: 34017

2021-06-08 12:49:25.972 5944-5984/com.xxx E/HMSSDK_HmsInstanceId: TokenTask failed, ErrorCode: 907135003

This error code indicates that The HMS Core SDK fails to connect to HMS Core (APK). The possible cause is that the HMS Core process is stopped or crashed.

On a non-Huawei mobile phone, the HMS Core, as a third-party application, may be killed by the system process. As a result, the HMS Core may cannot be used.

In addition, the HMS Core APK is also required on non-Huawei phones.The application performs a boot upgrade. If the system prompts you to upgrade the HMS Core APK, perform operations as prompted.

Upvotes: 1

Emre D.
Emre D.

Reputation: 579

<meta-data     
       android:name="push_kit_auto_init_enabled"  
       android:value="false" />

When we set auto init false in hms-push package it worked. There is another problem for ios devices. Package should be updated.

Upvotes: 2

Related Questions