eclipse / paho.mqtt.android

MQTT Android
Other
2.92k stars 881 forks source link

java.lang.NullPointerException Attempt to invoke virtual method 'void org.eclipse.paho.android.service.MqttService.traceError(java.lang.String, java.lang.String)' on a null object reference #250

Open jianglijs opened 6 years ago

jianglijs commented 6 years ago

org.eclipse.paho.android.service.MqttAndroidClient.void simpleAction(org.eclipse.paho.client.mqttv3.IMqttToken,android.os.Bundle)(MqttAndroidClient.java:1504) org.eclipse.paho.android.service.MqttAndroidClient.void sendAction(android.os.Bundle)(MqttAndroidClient.java:1516) org.eclipse.paho.android.service.MqttAndroidClient.void onReceive(android.content.Context,android.content.Intent)(MqttAndroidClient.java:1383) android.support.v4.content.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:297) android.support.v4.content.LocalBroadcastManager.access$000(LocalBroadcastManager.java:46) android.support.v4.content.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:116) android.os.Handler.dispatchMessage(Handler.java:110) android.os.Looper.loop(Looper.java:203) android.app.ActivityThread.main(ActivityThread.java:6434) java.lang.reflect.Method.invoke(Native Method) com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1113) com.android.internal.os.ZygoteInit.main(ZygoteInit.java:974)

jpwsutton commented 6 years ago

Hi,

Just pasting a stack trace into a bug isn't particularly helpful, please could you provide the information requested in the template you deleted:

jianglijs commented 6 years ago

library version:

I don't how it occured.Because all action is async,i think you just need to add null judgment before calling the methods of mqttService.

thanks.

ltigers commented 6 years ago

me ,too.

JonaNorman commented 5 years ago

me to, how to solve it

anoop4real commented 5 years ago

I am also getting this how to fix?

anoop4real commented 5 years ago

Found the problem for me, the format of host should be

"tcp://" + hostname+ ":" + port .. I missed tcp.

elinkthings commented 3 years ago

me ,too.

henriquerochamattos commented 2 years ago

I'm brazilian. So any mistakes forgive me. In your error message you mentioned BroadcastManager so try to put implementation 'androidx.localbroadcastmanager:localbroadcastmanager:1.0.0' in the build.gradle of app and if it persists put android.enableJetifier=true in the gradle.properties. I hope it solves it.