[Flutter] Android app crash when using Backendless.rt.addConnectListener/Backendless.rt.addDisconnectListener

Hello, the Android app crashed when I added this code:

Backendless.rt.addConnectListener(() {
      print("Backendless client connected");
    });

    Backendless.rt.addDisconnectListener((result) {
      print("Backendless client disconnected");
    });

Here is error log:

E/EventThread(11013): Task threw exception
E/EventThread(11013): java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. Current thread: EventThread
E/EventThread(11013): 	at io.flutter.embedding.engine.FlutterJNI.ensureRunningOnMainThread(FlutterJNI.java:1415)
E/EventThread(11013): 	at io.flutter.embedding.engine.FlutterJNI.dispatchPlatformMessage(FlutterJNI.java:1036)
E/EventThread(11013): 	at io.flutter.embedding.engine.dart.DartMessenger.send(DartMessenger.java:282)
E/EventThread(11013): 	at io.flutter.embedding.engine.dart.DartExecutor$DefaultBinaryMessenger.send(DartExecutor.java:470)
E/EventThread(11013): 	at io.flutter.embedding.engine.dart.DartExecutor.send(DartExecutor.java:223)
E/EventThread(11013): 	at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:120)
E/EventThread(11013): 	at io.flutter.plugin.common.MethodChannel.invokeMethod(MethodChannel.java:105)
E/EventThread(11013): 	at com.backendless.backendless_sdk.call_handlers.RtCallHandler$EventResult.handle(RtCallHandler.java:163)
E/EventThread(11013): 	at com.backendless.rt.RTServiceImpl.handle(RTServiceImpl.java:137)
E/EventThread(11013): 	at com.backendless.rt.RTServiceImpl.access$100(RTServiceImpl.java:9)
E/EventThread(11013): 	at com.backendless.rt.RTServiceImpl$1.handle(RTServiceImpl.java:27)
E/EventThread(11013): 	at com.backendless.rt.RTServiceImpl$1.handle(RTServiceImpl.java:23)
E/EventThread(11013): 	at com.backendless.rt.RTClientSocketIO$1.connected(RTClientSocketIO.java:47)
E/EventThread(11013): 	at com.backendless.rt.SocketIOConnectionManager$7.call(SocketIOConnectionManager.java:97)
E/EventThread(11013): 	at io.socket.emitter.Emitter.emit(Emitter.java:117)
E/EventThread(11013): 	at io.socket.client.Socket.access$601(Socket.java:24)
E/EventThread(11013): 	at io.socket.client.Socket$5.run(Socket.java:186)
E/EventThread(11013): 	at io.socket.thread.EventThread.exec(EventThread.java:55)
E/EventThread(11013): 	at io.socket.client.Socket.emit(Socket.java:182)
E/EventThread(11013): 	at io.socket.client.Socket.onconnect(Socket.java:389)
E/EventThread(11013): 	at io.socket.client.Socket.onpacket(Socket.java:283)
E/EventThread(11013): 	at io.socket.client.Socket.access$100(Socket.java:24)
E/EventThread(11013): 	at io.socket.client.Socket$2$2.call(Socket.java:120)
E/EventThread(11013): 	at io.socket.emitter.Emitter.emit(Emitter.java:117)
E/EventThread(11013): 	at io.socket.client.Manager.ondecoded(Manager.java:427)
E/EventThread(11013): 	at io.socket.client.Manager.access$1600(Manager.java:30)
E/EventThread(11013): 	at io.socket.client.Manager$7.call(Manager.java:403)
E/EventThread(11013): 	at io.socket.parser.IOParser$Decoder.add(IOParser.java:105)
E/EventThread(11013): 	at io.socket.client.Manager.ondata(Manager.java:419)
E/EventThread(11013): 	at io.socket.client.Manager.access$1000(Manager.java:30)
E/EventThread(11013): 	at io.socket.client.Manager$2.call(Manager.java:370)
E/EventThread(11013): 	at io.socket.emitter.Emitter.emit(Emitter.java:117)
E/EventThread(11013): 	at io.socket.engineio.client.Socket.onPacket(Socket.java:551)
E/EventThread(11013): 	at io.socket.engineio.client.Socket.access$1000(Socket.java:36)
E/EventThread(11013): 	at io.socket.engineio.client.Socket$5.call(Socket.java:335)
E/EventThread(11013): 	at io.socket.emitter.Emitter.emit(Emitter.java:117)
E/EventThread(11013): 	at io.socket.engineio.client.Transport.onPacket(Transport.java:126)
E/EventThread(11013): 	at io.socket.engineio.client.transports.Polling.access$700(Polling.java:18)
E/EventThread(11013): 	at io.socket.engineio.client.transports.Polling$2.call(Polling.java:127)
E/EventThread(11013): 	at io.socket.engineio.parser.Parser.decodePayload(Parser.java:241)
E/EventThread(11013): 	at io.socket.engineio.client.transports.Polling._onData(Polling.java:135)
E/EventThread(11013): 	at io.socket.engineio.client.transports.Polling.onData(Polling.java:102)
E/EventThread(11013): 	at io.socket.engineio.client.transports.PollingXHR$5$1.run(PollingXHR.java:125)
E/EventThread(11013): 	at io.socket.thread.EventThread$2.run(EventThread.java:80)
E/EventThread(11013): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1137)
E/EventThread(11013): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:637)
E/EventThread(11013): 	at java.lang.Thread.run(Thread.java:1012)

I am using backendless_sdk: ^7.2.8

Hello, @long_nguyen.

We are investigating your issue.

Best Regards, Nikita.

1 Like

Internal ticket BKNDLSS-30959 has been created.
It’s already been solved. A new version of the SDK will be published in the next few minutes.

Best Regards, Nikita.

@long_nguyen you can get fix in 7.2.10 version. Please let me know if everything is ok now.

@Nikita_Fedorishchev This issue has been fixed in version 7.2.10. Thank you.