【问题标题】:Crash Executing Android APP targeting API 31 with Huawei HMS Base 6.1.0.302 on Android 12在 Android 12 上使用 Huawei HMS Base 6.1.0.302 执行针对 API 31 的 Android APP 崩溃
【发布时间】:2021-11-28 05:41:46
【问题描述】:

我已针对目标 API 31 更新了我的应用程序,现在我只在搭载 Android 12 的手机中执行时出现运行时崩溃。崩溃是:

E/AndroidRuntime: FATAL EXCEPTION: HuaweiApiManager
    Process: com.example.myapp, PID: 4873
    java.lang.IllegalArgumentException: com.example.myapp: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent.
    Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles.
        at android.app.PendingIntent.checkFlags(PendingIntent.java:375)
        at android.app.PendingIntent.getActivityAsUser(PendingIntent.java:458)
        at android.app.PendingIntent.getActivity(PendingIntent.java:444)
        at android.app.PendingIntent.getActivity(PendingIntent.java:408)
        at com.huawei.hms.api.b.getErrPendingIntent(HuaweiApiAvailabilityImpl.java:10)
        at com.huawei.hms.common.internal.BaseHmsClient.resolution(BaseHmsClient.java:3)
        at com.huawei.hms.common.internal.BaseHmsClient.checkAvailabilityAndConnect(BaseHmsClient.java:34)
        at com.huawei.hms.common.internal.BaseHmsClient.connect(BaseHmsClient.java:1)
        at com.huawei.hms.common.internal.HuaweiApiManager$ConnectionManager.connect(HuaweiApiManager.java:21)
        at com.huawei.hms.common.internal.HuaweiApiManager$ConnectionManager.sendRequest(HuaweiApiManager.java:24)
        at com.huawei.hms.common.internal.HuaweiApiManager.connectAndSendRequest(HuaweiApiManager.java:8)
        at com.huawei.hms.common.internal.HuaweiApiManager.handleMessage(HuaweiApiManager.java:7)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.os.HandlerThread.run(HandlerThread.java:67)

此错误与When will Push Kit include the android:exported attributes required for Android 12?有关

修复此错误的 HMS Base 版本的大致发布日期是多少?

【问题讨论】:

  • 感谢您的反馈。团队确认正在开发中,新版本将在未来几天内发布,发布时我会通知您。

标签: java android kotlin huawei-mobile-services huawei-push-notification


【解决方案1】:

基础SDK新版本已经发布:

implementation 'com.huawei.hms:base:6.2.0.300'

此问题已修复,您可以先显式依赖此版本的 base sdk,这应该可以解决问题。

【讨论】:

  • 谢谢!需要将此包添加到我的 build.gradle,现在应用程序启动没有任何问题。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-12-13
  • 1970-01-01
  • 2021-12-20
  • 2021-03-04
  • 1970-01-01
  • 1970-01-01
  • 2021-04-09
相关资源
最近更新 更多