华为帐号服务不可用,如何实现?
Huawei Account Kit not working, how to implement?
正在尝试将 Account Kit 实施到我们的应用程序中,但它不起作用。
使用 com.huawei.hms:hwid:5.0.3.301 并在登录时显示空白 activity。从此空白处点击返回按钮 activity,日志将显示 onActivityResult 1002 0.
尝试从 https://github.com/HMS-Core/huawei-account-demo 构建演示项目。都是一样的,点击登录没有任何显示,点击返回按钮显示登录失败。
可能是什么问题?
#更新:
演示中缺少 ags 文件,因此空白 activity。添加 AGS 文件修复了它。
在验证本机 android SDK 构建在我的设备上运行后,继续尝试在 Unity 上实施。
已下载 4.0.4.300 AccountSDK 和 4.0.4.301 核心。 运行 APK 出现以下错误:
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)
然后我将桥 activity 从 HMSSdkUI 的清单复制到我的清单中并构建了应用程序:
<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>
但是,请求登录仍然会导致空白 activity。这是日志:我怀疑它与 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
错误代码10020表示参数无效。
你能检查一下你是否添加了正确的参数吗?
参考华为官方文档 how to sign in using huawei id.
您使用的是HMS Analytics kit吗,因为10020代码是analytics kit的错误代码。查看分析工具包的错误代码:
https://developer.huawei.com/consumer/en/doc/development/HMSCore-References-V5/android-api-error-code-0000001050987233-V5
如果您想实施帐户工具包,以下是可以帮助您解决问题的链接:
在您的示例中,您正在实施帐户工具包和分析工具包的组合,分析工具包将 return 此 10020 代码,检查下面 URl 以了解您的实施目的帐户工具包参考
在演示中,如果您点击登录,应用程序将尝试获取对您的华为帐号的授权。请检查您在HMSphone上是否运行以及华为账号是否登录
github里的demo有点旧,可以直接去official page下载代码。 github 演示将尽快更新。
更新:
- 请修改app目录下build.gradle文件中的xxx.jks信息
- 请在AGC平台create a project设置SHA256信息在xxx.jks文件中AGC平台。
- 请从AGC平台下载agconnect-services.json文件,并将文件放在项目的app目录下。
正在尝试将 Account Kit 实施到我们的应用程序中,但它不起作用。
使用 com.huawei.hms:hwid:5.0.3.301 并在登录时显示空白 activity。从此空白处点击返回按钮 activity,日志将显示 onActivityResult 1002 0.
尝试从 https://github.com/HMS-Core/huawei-account-demo 构建演示项目。都是一样的,点击登录没有任何显示,点击返回按钮显示登录失败。
可能是什么问题?
#更新: 演示中缺少 ags 文件,因此空白 activity。添加 AGS 文件修复了它。
在验证本机 android SDK 构建在我的设备上运行后,继续尝试在 Unity 上实施。
已下载 4.0.4.300 AccountSDK 和 4.0.4.301 核心。 运行 APK 出现以下错误:
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)
然后我将桥 activity 从 HMSSdkUI 的清单复制到我的清单中并构建了应用程序:
<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>
但是,请求登录仍然会导致空白 activity。这是日志:我怀疑它与 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
错误代码10020表示参数无效。 你能检查一下你是否添加了正确的参数吗? 参考华为官方文档 how to sign in using huawei id.
您使用的是HMS Analytics kit吗,因为10020代码是analytics kit的错误代码。查看分析工具包的错误代码: https://developer.huawei.com/consumer/en/doc/development/HMSCore-References-V5/android-api-error-code-0000001050987233-V5
如果您想实施帐户工具包,以下是可以帮助您解决问题的链接:
在您的示例中,您正在实施帐户工具包和分析工具包的组合,分析工具包将 return 此 10020 代码,检查下面 URl 以了解您的实施目的帐户工具包参考
在演示中,如果您点击登录,应用程序将尝试获取对您的华为帐号的授权。请检查您在HMSphone上是否运行以及华为账号是否登录
github里的demo有点旧,可以直接去official page下载代码。 github 演示将尽快更新。
更新:
- 请修改app目录下build.gradle文件中的xxx.jks信息
- 请在AGC平台create a project设置SHA256信息在xxx.jks文件中AGC平台。
- 请从AGC平台下载agconnect-services.json文件,并将文件放在项目的app目录下。