Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Neither aws-android-sdk-iot nor org.eclipse.paho.client.mqttv3 provide appropriate ProGuard/R8 rules #3461

Open
azabost opened this issue Nov 9, 2023 · 1 comment
Labels
feature-request Request a new feature

Comments

@azabost
Copy link

azabost commented Nov 9, 2023

Describe the bug
When aws-android-sdk-iot is used in an Android app with R8/ProGuard enabled, then the essential code gets removed and the library doesn't work properly.

For example, I stumbled upon this exception (stacktrace deobfuscated by retrace):

java.util.MissingResourceException: Error locating the logging class
	at org.eclipse.paho.client.mqttv3.logging.LoggerFactory.getLogger(LoggerFactory.java:76)
	at org.eclipse.paho.client.mqttv3.TimerPingSender.<init>(TimerPingSender.java:34)
	at org.eclipse.paho.client.mqttv3.MqttAsyncClient.<init>(MqttAsyncClient.java:317)
	at com.amazonaws.mobileconnectors.iot.AWSIotMqttManager.connect(AWSIotMqttManager.java:918)
	at com.amazonaws.mobileconnectors.iot.AWSIotMqttManager.connect(AWSIotMqttManager.java:869)

In that particular case, I guess that, ideally, it should be fixed in https://github.com/eclipse/paho.mqtt.java/ and I've already found an open issue there (eclipse-paho/paho.mqtt.java#776) but it's very old and nobody seems to care, so perhaps at least you could fix it on your side instead?

To Reproduce
Just try to invoke AWSIotMqttManager.connect in a build where code shrinking was enabled, e.g. release in this case:

android {  
    buildTypes {
        getByName("release") {
            isMinifyEnabled = true // <-- this
            isShrinkResources = true
            proguardFiles(
                getDefaultProguardFile("proguard-android-optimize.txt"),
                "proguard-rules.pro"
            )
        }
    }
}

Which AWS service(s) are affected?
aws-android-sdk-iot

Expected behavior
The library can successfully connect and function properly.

Screenshots
n/a

Environment Information (please complete the following information):

  • AWS Android SDK Version: com.amazonaws:aws-android-sdk-iot:2.73.0
  • Android Gradle Plugin version: com.android.tools.build:gradle:8.1.3 (implies android.enableR8.fullMode=true)
  • Device: doesn't matter
  • Android Version: doesn't matter
  • Specific to simulators: No

Additional context
n/a

@tylerjroach
Copy link
Member

Thank you for the report. We will look on improving our proguard rules for IoT.

@ankpshah ankpshah added the feature-request Request a new feature label Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request a new feature
Projects
None yet
Development

No branches or pull requests

3 participants