eclipse / paho.mqtt.android

MQTT Android
Other
2.92k stars 881 forks source link

Possibly remove support libraries from the Android Paho client? #153

Open mdeneen opened 7 years ago

mdeneen commented 7 years ago

Please fill out the form below before submitting, thank you!

Android API Version Bug Seen on: 19 Android Version Bug Seen on: 4.4.4

Please also check that if you have found the bug in the Release version (1.1.0) that you check that it also exists in the Snapshot (1.1.1-SNAPSHOT) before raising a bug.

Description of Bug:

E.g. Steps to re-create, how often does this happen etc.. Build Android Paho Client. The APK is about 1.8MB. If you remove the Android support libraries and replace LocalBroadcastManager with a copy of the java file from https://github.com/android/platform_frameworks_support/blob/master/v4/java/android/support/v4/content/LocalBroadcastManager.java (change the package + references), the APK is significantly smaller.

In my case, I was able to reduce the APK size of a simple application which uses the paho android service from 1.8MB to 120KB.

I don't know if the goal of the android client is to reduce package size, but this is pretty significant. It would also make usage of the android service much easier since you do not need to exclude the support libraries in gradle. See https://github.com/eclipse/paho.mqtt.android/issues/79#issuecomment-219674157

Console Log output (if available):

paulo-raca commented 7 years ago

I had a related issue: On runtime, it crashes with java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/content/LocalBroadcastManager; (I'm using version 1.1.0) Copying this file into my project fixed it, thanks :)

jpwsutton commented 7 years ago

So after a bit more thought, There shouldn't be a legal issue with pulling the source code into the project as it's licensed under Apache 2.0. However it could cause a bit of a maintenance headache for us. The nice thing about the support library is that we just have to update the version every once in a while and it pulls in all of the changes and improvements as well as making it easy to support multiple versions of Android.

If we were to pull the LocalBroadcastManager class into Paho, we would then need to make sure that we kept in step with any changes manually, or risk breaking support for newer or older versions of Android.

I'll have a play around at some point to see exactly how much code we would need to pull in. If it's a manageable amount that won't incur too much maintenance then I might pull it in. It would definitely be nice to slim down the library!

mdeneen commented 7 years ago

It's worth noting that LocalBroadcastManager has had one change since 2011, and that change was adding "final" to the class definition.

jpwsutton commented 7 years ago

Good point! Safe to say there won't be a huge amount of maintenance needed then. Thanks!

gpism commented 7 years ago

when this would be closed ? support library is making paho really bloated