华为帐号工具包无法正常工作,如何实现?

huangapple go评论75阅读模式
英文:

Huawei Account Kit not working, how to implement?

问题

尝试将Account Kit集成到我们的应用中,但无法正常工作。

使用com.huawei.hms:hwid:5.0.3.301,在登录时显示空白活动。从这个空白活动点击返回按钮,日志会显示onActivityResult 1002 0。

尝试构建来自https://github.com/HMS-Core/huawei-account-demo的演示项目。情况是一样的,点击登录没有任何显示,点击返回按钮会显示登录失败。

可能出了什么问题?

#更新:
演示文件缺少ags文件,因此显示空白活动。添加ags文件后问题得以解决。

在确认原生Android SDK构建在我的设备上正常工作后,继续尝试在Unity中进行集成。

下载了4.0.4.300的AccountSDK和4.0.4.301的Core。运行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)
        ...

然后我从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>

然而,请求登录仍然导致空白活动。以下是日志内容:我怀疑与BridgeActivity有关吗?

2020-10-09 16:02:17.063 ... Builder->biInitFlag :false
2020-10-09 16:02:17.064 ... Builder->biSetting :false
...
2020-10-09 16:02:17.151 ... Start to resolution for the 1st time.
2020-10-09 16:02:17.151 ... startResolution
...
2020-10-09 16:02:17.279 ... Run time Exception.String resource ID #0x0
2020-10-09 16:02:17.279 ... Enter finish.

请注意,以上是你提供的文本的翻译。如有问题,请随时提问。

英文:

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)&#160;
        at android.app.ActivityThread.-wrap11(Unknown Source:0)&#160;
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)&#160;
        at android.os.Handler.dispatchMessage(Handler.java:105)&#160;
        at android.os.Looper.loop(Looper.java:164)&#160;
        at android.app.ActivityThread.main(ActivityThread.java:6938)&#160;
        at java.lang.reflect.Method.invoke(Native Method)&#160;
        at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)&#160;
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)&#160;

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

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

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-&gt;biInitFlag :false
2020-10-09 16:02:17.064 20598-20598/? I/HMSSDK_HMSBIInitializer: Builder-&gt;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

答案1

得分: 0

错误代码10020表示参数无效。
您能否检查您是否添加了正确的参数。
请参阅华为官方文档,了解如何使用华为帐号进行登录

英文:

Error code 10020 means invalid parameters.
Can you check if you are adding correct parameter.
Refer Huawei official document on how to sign in using huawei id.

答案2

得分: 0

你是否在使用HMS Analytics Kit,因为10020代码是分析套件的错误代码。请查看分析套件的错误代码:https://developer.huawei.com/consumer/en/doc/development/HMSCore-References-V5/android-api-error-code-0000001050987233-V5

如果您想要实现帐户套件,以下是可以帮助您并可能能够解决问题的链接:

  1. https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201272938220820099&amp;fid=0101187876626530001

  2. https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201206040914750083&amp;fid=0101187876626530001

英文:

Are you using HMS Analytics kit because 10020 code is the error code of analytics kit. Check out error codes of analytics kit:
https://developer.huawei.com/consumer/en/doc/development/HMSCore-References-V5/android-api-error-code-0000001050987233-V5

If you want to implement Account kit, below are the links which can help you out and may be you will be able to figure it out your problem:

  1. https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201272938220820099&amp;fid=0101187876626530001

  2. https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201206040914750083&amp;fid=0101187876626530001

答案3

得分: 0

在您的示例中,您正在实现Account Kit和Analytics Kit的组合,Analytics Kit将返回这个10020代码,请查看以下链接以获取您的实现目的,Account Kit参考:

https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201231030637780065&amp;fid=0101187876626530001

英文:

in your sample you are implementing combination of account kit and analytics kit ,analytics kit will return this 10020 Code ,check below URl for you're Implementation purpose Account kit reference

https://forums.developer.huawei.com/forumPortal/en/topicview?tid=0201231030637780065&amp;fid=0101187876626530001

答案4

得分: 0

在演示中,如果您点击登录,应用程序将尝试获取授权访问您的华为帐户。请检查您是否在运行HMS手机上,并且华为帐户已登录。

GitHub上的演示有点过时,您可以直接从官方页面下载代码。GitHub上的演示将尽快更新。

更新:

  1. 请在应用程序目录中的build.gradle文件中修改xxx.jks信息。
  2. 请在AGC平台上创建一个项目,并在AGC平台上的xxx.jks文件中设置SHA256信息。
  3. 请从AGC平台下载agconnect-services.json文件,并将该文件放置在项目的应用程序目录中。
英文:

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.

华为帐号工具包无法正常工作,如何实现?

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.

huangapple
  • 本文由 发表于 2020年10月1日 22:22:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/64157379.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定