HiveMQ MQTT Client Features: Android Support
Written by Silvio Giebl
Published: July 23, 2019
Welcome to the HiveMQ MQTT Client Features blog post series.
Last time we looked at the Fluent API style. Today we will take a closer look at the Android support of the HiveMQ MQTT Client library.
In general, the HiveMQ MQTT Client library is supported on Android 4.4 (API level 19) and higher versions. According to Google’s statistics this covers more than 95% of all running Android devices.
Independently of the supported API level, you have to grant your app the permission to use internet communication.
Here is how you configure the permission in the
Support for Android API levels 24+
As the HiveMQ MQTT Client uses Java 8 language features, you have to specify the following in the app’s
Additionally you have to set some proguard rules in the app’s
Please make sure that the
proguard-rules.pro file is referenced in the app’s
Support for Android API levels 19+
The above configuration is enough if your minimum supported Android API level is at least 24 (7.0 Nougat).
Targeting lower Android versions requires additional configuration as Android still lacks support for Java 8 APIs like
java.util.concurrent.CompletableFuture on versions below 24.
You can use the Android RetroFix gradle plugin to backport these APIs automatically. This plugin enables you to use the Java 8 APIs even if you have to support lower Android versions.
The following shows how to configure the Android RetroFix plugin in the app’s
You have to add the plugin and the two backport dependencies
When you increase the Android API level to 24+ in the future, you will only need to remove the plugin and the backport dependencies. You do not have to change your code.
For more information regarding Android support of the HiveMQ MQTT Client library, please refer to the project documentation.
If you have not already done so, check out the project on GitHub.
Have a great day, Silvio from the HiveMQ Team