小编Jos*_*fem的帖子

Android paho mqtt 导致 Android 12 崩溃 - 定位 S+(版本 31 及更高版本)需要 FLAG_IMMUTABLE 或 FLAG_MUTABLE 之一

我正在使用 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5' 作为 mqtt 服务,并且该应用程序在 Android 12 设备上不断崩溃,并显示以下崩溃日志

java.lang.IllegalArgumentException: app id: 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:382)
        at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:673)
        at android.app.PendingIntent.getBroadcast(PendingIntent.java:660)
        at org.eclipse.paho.android.service.AlarmPingSender.start(AlarmPingSender.java:76)
        at org.eclipse.paho.client.mqttv3.internal.ClientState.connected(ClientState.java:1214)
        at org.eclipse.paho.client.mqttv3.internal.ClientState.notifyReceivedAck(ClientState.java:1050)
        at org.eclipse.paho.client.mqttv3.internal.CommsReceiver.run(CommsReceiver.java:151)
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的库:

implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
Run Code Online (Sandbox Code Playgroud)

java kotlin android-pendingintent paho android-12

9
推荐指数
2
解决办法
1万
查看次数

标签 统计

android-12 ×1

android-pendingintent ×1

java ×1

kotlin ×1

paho ×1