flutter_bluetooth_serial icon indicating copy to clipboard operation
flutter_bluetooth_serial copied to clipboard

Flutter_Bluetooth_Serial getBluetoothService() called with no BluetoothManagerCallback Error

Open Amin-Matola opened this issue 4 years ago • 9 comments

I am trying to connect to bluetooth device using flutter bluetooth serial library ^0.2.2, on flutter 1.20.2, but everytime I run the code, I get the following error:

C:\Users\Me>...
D/FlutterBluePlugin(16512): Starting discovery
D/BluetoothAdapter(16512): startDiscovery
D/BluetoothAdapter(16512): startDiscovery = true
D/FlutterBluePlugin(16512): Discovered B8:27:EB:C9:45:29
D/FlutterBluePlugin(16512): Discovery finished
D/BluetoothAdapter(16512): cancelDiscovery
D/BluetoothAdapter(16512): cancelDiscovery = true
D/FlutterBluePlugin(16512): Canceling discovery (stream closed)
D/BluetoothAdapter(16512): cancelDiscovery
D/BluetoothAdapter(16512): cancelDiscovery = true
D/FlutterBluePlugin(16512): Connecting to B8:27:EB:C9:45:29 (id: 3)
D/BluetoothAdapter(16512): cancelDiscovery
D/BluetoothAdapter(16512): cancelDiscovery = true
D/BluetoothUtils(16512): isSocketAllowedBySecurityPolicy start : device null
D/BluetoothSocket(16512): connect(): myUserId = 0
W/BluetoothAdapter(16512): getBluetoothService() called with no BluetoothManagerCallback
E/System  (16512): Uncaught exception thrown by finalizer
E/System  (16512): java.io.IOException: socket not created
E/System  (16512): 	at android.net.LocalSocketImpl.shutdownInput(LocalSocketImpl.java:396)
E/System  (16512): 	at android.net.LocalSocket.shutdownInput(LocalSocket.java:206)
E/System  (16512): 	at android.bluetooth.BluetoothSocket.close(BluetoothSocket.java:793)
E/System  (16512): 	at android.bluetooth.BluetoothSocket.finalize(BluetoothSocket.java:308)
E/System  (16512): 	at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:217)
E/System  (16512): 	at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:200)
E/System  (16512): 	at java.lang.Thread.run(Thread.java:818)
E/System  (16512): Uncaught exception thrown by finalizer
E/System  (16512): java.io.IOException: socket not created
E/System  (16512): 	at android.net.LocalSocketImpl.shutdownInput(LocalSocketImpl.java:396)
E/System  (16512): 	at android.net.LocalSocket.shutdownInput(LocalSocket.java:206)
E/System  (16512): 	at android.bluetooth.BluetoothSocket.close(BluetoothSocket.java:793)
E/System  (16512): 	at android.bluetooth.BluetoothSocket.finalize(BluetoothSocket.java:308)
E/System  (16512): 	at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:217)
E/System  (16512): 	at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:200)
E/System  (16512): 	at java.lang.Thread.run(Thread.java:818)

My code to connect the device is...

Future<void> connect(address) async {

    BluetoothConnection.toAddress(address).then((conn){
      print("Connected to device $address");
      conn.input.listen((Uint8List event) {
        print(event);
      }).onDone(() {
        print("Closing connection");
        conn.close();
      });
      showDialog(context: context, builder: (d){
        return AlertDialog(
          title: Text("Connection Successful"),
          content: Text("Connected to device $address"),
          actions: [
            FlatButton(
              child: Text("Ok"),
              onPressed: (){
                Navigator.pop(context);
              },
            )
          ],
        );
      });
    })
    .catchError((error){
          showDialog(context: context, builder: (d){
            return AlertDialog(
              title: Text("Connection Problem!", style: TextStyle(color: Colors.red,),),
              content: Text("There was an error connecting to device $address", style: TextStyle(color: Colors.grey[600]),),
              actions: [
                FlatButton(
                  child: Text("Ok"),
                  onPressed: (){
                    Navigator.pop(context);
                  },
                )
              ],
            );
          });
        });
  }

Amin-Matola avatar Sep 04 '20 08:09 Amin-Matola

What Android version are you using?

AgainPsychoX avatar Oct 16 '20 21:10 AgainPsychoX

What Android version are you using?

Well, I ran the app on both "Android 6 and 7", all to notice the same!

Amin-Matola avatar Oct 19 '20 11:10 Amin-Matola

When will you resolve this issue. I need to connect my BT headsets for live audio transmission. but on connection I get this error.

umamakhalid avatar Oct 21 '20 04:10 umamakhalid

Could you solve this problem? I also face with this error. I run Android app on two android device and they cannot connect to chat.

patzu avatar Jan 08 '21 08:01 patzu

No sorry. I have stop using flutter as there was no fine solution to this problem on internet.

On Fri, Jan 8, 2021, 1:40 PM Patzu [email protected] wrote:

Could you solve this problem? I also face with this error. I run Android app on two android device and they cannot connect to chat.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/edufolly/flutter_bluetooth_serial/issues/101#issuecomment-756626873, or unsubscribe https://github.com/notifications/unsubscribe-auth/AG5QVMOYIBG3CLNYUMT6DPDSY3AG5ANCNFSM4QXVMOQA .

umamakhalid avatar Jan 08 '21 08:01 umamakhalid

Same here. Using android 10.

devfelipereis avatar Feb 01 '21 17:02 devfelipereis

Same here. Using android 8.0.

Luffys6 avatar Sep 03 '21 06:09 Luffys6

Has anyone solved this problem?

coyksdev avatar Dec 10 '21 04:12 coyksdev

Anyone solved this issue?

sayanlp99 avatar Aug 28 '23 16:08 sayanlp99