[SOLVED] Safety Detect returns error “need update kit”


This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under
CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

Issue

I have a problem with Safety Detect SDK. When I’m trying to generate token I’ve got error from SDK that I need to update kit. Error code is 1212. I’ve checked on webpage href=”https://developer.huawei.com/consumer/en/doc/development/hmscore-common-References/error-code-0000001050045846″ rel=”nofollow noreferrer”>https://developer.huawei.com/consumer/en/doc/development/hmscore-common-References/error-code-0000001050045846 that I need to update it in App Gallery but In App Gallery I don’t have any updates. I’ve tried on two same phones (P40 lite) and error occures only on one of them. They have same version of HMS Core (6.6.0.332) , same version of OS (Android 12). I though it was combined with push-kit but I’ve updated agcp library with version 1.6.0.300 and push kit with version 6.5.0.300 without any luck. Maybe someone had the same problem with some other kits. Code which I’m using to generate token is pased below:

String appId = AGConnectServicesConfig.fromContext(cordova.getContext()).getString("client/app_id");
  SafetyDetectClient mClient = SafetyDetect.getClient(getApplicationContext());
  Task<SysIntegrityResp> task = mClient.sysIntegrity(nonce.getBytes(StandardCharsets.UTF_8), appId);
  task.addOnSuccessListener(response -> {
    Log.i(TAG, "Success getting token");
  }).addOnFailureListener(e -> {
    if (e instanceof ApiException) {
      ApiException apiException = (ApiException) e;
      Log.e("SysIntegrity", "Error: " + SafetyDetectStatusCodes.getStatusCodeString(apiException.getStatusCode()) + ": " + apiException.getMessage());
    
    } else {
      Log.e("SysIntegrity", "ERROR:" + e.getMessage());
    }
  });

I’ll be very glad if someone could point me where I could update that.

Solution

Error code 1212 indicates that the subapplication of the HMS Core needs to be upgraded. The possible cause is that the Safety Detect apk is not installed or updated on your test device due to network or other reasons.

You can refer to the following command to collect log:

 1) After adb is connected to the phone, execute the following commands:

a. adb shell setprop log.tag.hwpush VERBOSE
b. adb logcat -v threadtime 1> D:hwSafetyDetect .log

 2) Reproduce the problem scene.

 3) Press “Ctrl+C” to finish.

Answered By – zhangxaochen

people found this article helpful. What about you?