paho.mqtt.android icon indicating copy to clipboard operation
paho.mqtt.android copied to clipboard

Replace deprecated support.v4 classes with androidx

Open nuno-silva opened this issue 4 years ago • 7 comments

The LocalBroadcastManager is part of the Android support library, which is no longer maintained.

Therefore, android.support.v4.content.LocalBroadcastManager class used by https://github.com/eclipse/paho.mqtt.android/blob/3cb8af72f21b56ba72a6a6ddf3066d07d42f80b5/org.eclipse.paho.android.service/src/main/java/org/eclipse/paho/android/service/MqttAndroidClient.java#L58 is deprecated.

This has caused many issues already (e.g. #378 and #321) because it is not automatically linked in anymore. The workarounds I've seen are:

  • setting android.enableJetifier=true in gradle.properties (https://github.com/eclipse/paho.mqtt.android/issues/321#issuecomment-531628464), which doesn't seem to work anymore
  • adding implementation 'androidx.legacy:legacy-support-v4:1.0.0' to build.grade (https://github.com/eclipse/paho.mqtt.android/issues/321#issuecomment-533602703)
  • ...

However, these workarounds do not fix the core issue and encourage people to use deprecated/unmaintained libraries. Instead, this class (and any other belonging to the support v4 lib) should be replaced by an equivalent class from AndroidX libraries.

There's a migration guide available.

android.support.v4.content.LocalBroadcastManager maps to androidx.localbroadcastmanager.content.LocalBroadcastManager.

nuno-silva avatar Jul 12 '20 01:07 nuno-silva

I feel I must empahasize this request! Building a new app from scratch and having to include umaintained libraries for it to work leaves me a bit insecure of how to cope with this in my project.

msdn65 avatar Aug 11 '20 06:08 msdn65

I agree

cyixlq avatar Sep 29 '20 08:09 cyixlq

Agree :) it was very useful

RogelioRosas avatar May 27 '21 20:05 RogelioRosas

I agree

chenzhaohe avatar Jun 09 '21 07:06 chenzhaohe

I agree

ZRainH avatar Aug 27 '21 07:08 ZRainH

This is pretty old, so not expecting this to get fixed, but while I too agree, I have working results when including "android.enableJetifier=true" setting and wanted to chime in for anyone else who happens to look here in same boat as me. I'm not sure exactly what's different between my project and OP's (and others from looks of mixed results in linked issue), but I do tend to keep all other libs and plugins up-to-date. That said, if that jetifier setting isn't working for you, look into outdated components to your project, starting with the com.android.tools.build:gradle version you're using.

jschleppy avatar Jun 01 '22 01:06 jschleppy