Search code examples
javaandroidunity-game-enginehuawei-mobile-serviceshuawei-account

Huawei Account Kit not working, how to implement?


trying to implement Account Kit into our app and it is not working.

Using com.huawei.hms:hwid:5.0.3.301 and on signin, blank activity is shown. Hitting back button from this blank activity, log would show onActivityResult 1002 0.

Tried building the demo project from https://github.com/HMS-Core/huawei-account-demo. It is the same thing, clicking on login nothing shows, clicking back button would show signin failed.

What could be the issue?

#UPDATE: ags file was missing from demo, hence the blank activity. Adding the AGS file fixed it.

After verifying that the native android SDK build does work on my device, continued trying to implement on Unity.

Downloaded 4.0.4.300 AccountSDK with 4.0.4.301 Core. Ran the APK and the following error occured:

     Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.test.test.huawei/com.huawei.hms.activity.BridgeActivity}; have you declared this activity in your AndroidManifest.xml?
        at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1950)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1622)
        at android.app.Activity.startActivityForResult(Activity.java:4564)
        at android.app.Activity.startActivityForResult(Activity.java:4522)
        at android.app.Activity.startActivity(Activity.java:4883)
        at android.app.Activity.startActivity(Activity.java:4851)
        at com.huawei.hms.adapter.AvailableAdapter.startResolution(AvailableAdapter.java:155)
        at com.huawei.hms.hwid.a.a.a(HmsAPKVersionCheckUtil.java:46)
        at com.huawei.hms.hwid.internal.ui.activity.HwIdSignInHubActivity.a(HwIdSignInHubActivity.java:212)
        at com.huawei.hms.hwid.internal.ui.activity.HwIdSignInHubActivity.onCreate(HwIdSignInHubActivity.java:106)
        at android.app.Activity.performCreate(Activity.java:7174)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2908)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030) 
        at android.app.ActivityThread.-wrap11(Unknown Source:0) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696) 
        at android.os.Handler.dispatchMessage(Handler.java:105) 
        at android.os.Looper.loop(Looper.java:164) 
        at android.app.ActivityThread.main(ActivityThread.java:6938) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) 

So then I copied the bridge activity from the HMSSdkUI's manifest into my manifest and the the app built:

        <activity
            android:name="com.huawei.hms.activity.BridgeActivity"
            android:configChanges="orientation|locale|layoutDirection|fontScale|screenSize|smallestScreenSize|screenLayout"
            android:excludeFromRecents="true"
            android:exported="false"
            android:hardwareAccelerated="true"
            android:screenOrientation="behind"
            android:theme="@android:style/Theme.Translucent" >
            <meta-data
                android:name="hwc-theme"
                android:value="androidhwext:style/Theme.Emui.Translucent" />
        </activity>

However, requesting sign in still results in blank activity. Here is the log: I am suspecting it has to do with the BridgeActivity??

2020-10-09 16:02:17.063 20598-20598/? I/HMSSDK_HMSBIInitializer: Builder->biInitFlag :false
2020-10-09 16:02:17.064 20598-20598/? I/HMSSDK_HMSBIInitializer: Builder->biSetting :false
2020-10-09 16:02:17.065 20598-20598/? I/HMSSDK_CountryCodeBean: getCountryCode get country code from SIM_COUNTRY
2020-10-09 16:02:17.068 20598-20598/? I/HMSSDK_CountryCodeBean: getCountryCode get country code from SIM_COUNTRY
2020-10-09 16:02:17.070 20598-20598/? W/NetworkKit_AbstractLocalManager: 20598-20598|null|com.huawei.hms.framework.network.grs.local.a|a|16|addresses not found by routeby in local config{com.huawei.cloud.opensdkhianalytics}
2020-10-09 16:02:17.072 20598-23397/? E/HMSSDK_HMSBIInitializer: get grs failed, the errorcode is -3
2020-10-09 16:02:17.075 1565-3643/? I/ActivityManager: START u0 {act=com.huawei.hms.jos.signIn typ=null flg=0x0 cmp=ComponentInfo{com.test.test.huawei/com.huawei.hms.hwid.internal.ui.activity.HwIdSignInHubActivity}} from uid 10935
2020-10-09 16:02:17.100 1565-2477/? D/GameManagerService: handleForegroundChange(). pkgName: com.test.test.huawei, clsName: com.huawei.hms.hwid.internal.ui.activity.HwIdSignInHubActivity,FgActivityName:com.test.test.huawei/com.huawei.hms.hwid.internal.ui.activity.HwIdSignInHubActivity
2020-10-09 16:02:17.140 20598-20598/? I/HMSSDK_[HUAWEIIDSDK]HwIdSignInClientHub: onCreate
2020-10-09 16:02:17.143 20598-20598/? I/HMSSDK_HiAnalyticsUtil: not ChinaROM
2020-10-09 16:02:17.144 20598-20598/? I/HMSSDK_HiAnalyticsUtil: Get OOBE failed
2020-10-09 16:02:17.144 20598-20598/? I/HMSSDK_HmsAPKVersionCheckUtil: ====== HMSSDK version: 40004300 ======
2020-10-09 16:02:17.144 20598-20598/? I/HMSSDK_HmsAPKVersionCheckUtil: check minVersion:30000000
2020-10-09 16:02:17.148 20598-20598/? E/HMSSDK_X509CertUtil: exception:updatesdkcas.bks
2020-10-09 16:02:17.148 20598-20598/? E/HMSSDK_X509CertUtil: rootCert is null,verify failed 
2020-10-09 16:02:17.149 20598-20598/? E/HMSSDK_HMSPackageManager: failed to verify cert chain
2020-10-09 16:02:17.149 20598-20598/? E/HMSSDK_HMSPackageManager: checkSinger failed
2020-10-09 16:02:17.149 20598-20598/? E/HMSSDK_HMSPackageManager: Failed to find HMS apk
2020-10-09 16:02:17.150 20598-20598/? I/HMSSDK_AvailableAdapter: HMS is not installed
2020-10-09 16:02:17.151 20598-20598/? I/HMSSDK_AvailableAdapter: enter 4.0 HmsCore upgrade process
2020-10-09 16:02:17.151 20598-20598/? I/HMSSDK_AvailableAdapter: Start to resolution for the 1st time.
2020-10-09 16:02:17.151 20598-20598/? I/HMSSDK_AvailableAdapter: startResolution
2020-10-09 16:02:17.156 1565-4083/? I/ActivityManager: START u0 {act=null typ=null flg=0x0 cmp=ComponentInfo{com.test.test.huawei/com.huawei.hms.activity.BridgeActivity}} from uid 10935
2020-10-09 16:02:17.184 1565-4083/? V/WindowManager: Relayout Window{fd32694 u0 com.test.test.huawei/com.huawei.hms.hwid.internal.ui.activity.HwIdSignInHubActivity}: viewVisibility=0 req=720x1336 WM.LayoutParams{(0,0)(fillxfill) sim=#120 ty=1 fl=#1810100 pfl=0x1020000 fmt=-2 wanim=0x1030000 vsysui=0x410 needsMenuKey=2 colorMode=0 naviIconColor=0}
2020-10-09 16:02:17.185 655-655/? I/SurfaceFlinger: id=14264 createSurf (720x1480),1 flag=4, com.test.test.huawei/com.huawei.hms.hwid.internal.ui.activity.HwIdSignInHubActivity#0
2020-10-09 16:02:17.231 1565-2477/? D/GameManagerService: handleForegroundChange(). pkgName: com.test.test.huawei, clsName: com.huawei.hms.activity.BridgeActivity,FgActivityName:com.test.test.huawei/com.huawei.hms.activity.BridgeActivity
2020-10-09 16:02:17.239 1565-3643/? V/WindowManager: finishDrawingLocked: mDrawState=COMMIT_DRAW_PENDING Window{fd32694 u0 com.test.test.huawei/com.huawei.hms.hwid.internal.ui.activity.HwIdSignInHubActivity} in Surface(name=com.test.test.huawei/com.huawei.hms.hwid.internal.ui.activity.HwIdSignInHubActivity)
2020-10-09 16:02:17.279 20598-20598/? E/HMSSDK_BridgeActivity: Run time Exception.String resource ID #0x0
2020-10-09 16:02:17.279 20598-20598/? I/HMSSDK_BridgeActivity: Enter finish.
2020-10-09 16:02:17.301 1565-2477/? D/GameManagerService: handleForegroundChange(). pkgName: com.test.test.huawei, clsName: com.huawei.hms.hwid.internal.ui.activity.HwIdSignInHubActivity,FgActivityName:com.test.test.huawei/com.huawei.hms.hwid.internal.ui.activity.HwIdSignInHubActivity
2020-10-09 16:02:17.316 1565-8502/? V/WindowManager: Relayout Window{fd32694 u0 com.test.test.huawei/com.huawei.hms.hwid.internal.ui.activity.HwIdSignInHubActivity}: viewVisibility=0 req=720x1384 WM.LayoutParams{(0,0)(fillxfill) sim=#120 ty=1 fl=#1810100 pfl=0x1020000 fmt=-2 wanim=0x1030000 vsysui=0x410 needsMenuKey=2 colorMode=0 naviIconColor=0}
2020-10-09 16:02:17.334 20598-20598/? I/HMSSDK_UpdateAdapter: onBridgeActivityDestroy

Solution

  • In the demo, if you click signin, app will try to get authorization to your Huawei Account. Please check whether you are running on the HMS phone and Huawei account is log in.

    The demo in the github is a little old, you can download the code from the official page directly. The github demo will be updated ASAP.

    sample code

    Update:

    1. Please modify the xxx.jks info in the build.gradle file in the app directory.
    2. Please create a project on the AGC platform and set the SHA256 information in the xxx.jks file on the AGC platform.
    3. Please download the agconnect-services.json file from the AGC platform and place the file in the app directory of the project.