Issue
I am using 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5' for mqtt service and the app keeps crashing on android 12 devices with the following crash logs
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)
This is the library I am using:
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
Solution
If you are using the MQTT library they have not updated for the Android 12. So when you use Android 12 as the target version it throws an error in PendingIntent. For a temporary solution, I had found a library they had upgraded for compatibility with Android 12. MQTT service library
Download the "serviceLibrary-release.aar" and add it to your project. Then remove the "'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1" dependency from Gradle. Use "import info.mqtt.android.service.MqttAndroidClient" wherever you are using.
This solved my MQTT library issues.
Answered By - Myself
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.