[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] Android Paho client on Andriod OS 8 (Oreo) issue

Dear all,

I am using the library org.eclipse.paho.client (https://www.hivemq.com/blog/mqtt-client-library-enyclopedia-paho-android-service) to implement a simple Android MQTT client which connects to our MQTT server.

Â

My Android MQTT client application worked properly until Android OS 7.x. Unfortunately, it is not working properly for Android 8 (Oreo version). Specifically, I received the following exceptions:

Â

ÂÂÂÂÂÂÂÂÂ android.app.ServiceConnectionLeaked: Activity.certh.gr.pedestrian.MainActivity has leaked ServiceConnection org.eclipse.paho.android.service.MqttAndroidClient$MyServiceConnection@4058b04 that was originally bound here

Â

ÂÂÂÂÂÂÂÂÂ android.app.IntentReceiverLeaked: Service org.eclipse.paho.android.service.MqttService has leaked IntentReceiver org.eclipse.paho.android.service.AlarmPingSender$AlarmReceiver@b9978a0 that was originally registered here. Are you missing a call to unregisterReceiver()?

Â

ÂÂÂÂÂÂÂÂÂ java.lang.IllegalStateException: Not allowed to start service Intent { cmp= certh.gr.pedestrian/org.eclipse.paho.android.service.MqttService }: app is in background uid UidRecord {61f9870 âââââââ}

Â

I followed the recommendations from Google for Androdi 8.0 (https://developer.android.com/about/versions/oreo/android-8.0-changes#back-all and https://developer.android.com/about/versions/oreo/background ) , so I changed my class to extend JobIntentService and use the enqueueWork().

In the MainActivityâs onCreate()Â I am calling the JobIntentService as following:

Â

Intent intentService = new Intent(MainActivity.this, SimpleJobIntentService.class);
intentService.putExtra(
"label", intentService.toString());

SimpleJobIntentService.enqueueWork(
this, intentService);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
ÂÂÂÂ startForegroundService(
new Intent(this, SimpleJobIntentService.class));
}
else {
ÂÂÂÂ startService(
new Intent(this, SimpleJobIntentService.class));
}

Â

where the SimpleJobIntentService is calling the MQTT connection (MqttConnectOptions)

I am using the paho library in gradle.build:

Âimplementation('org.eclipse.paho:org.eclipse.paho.android.service:1.0.2') {

ÂÂÂÂÂÂÂ exclude module: 'support-v4'

ÂÂÂ }

Â

I would like to ask you if there is any solution to this problem or if there is any newer version which is compliant with Android OS 8 (Oreo).

Â

Regards,

Kostas