kakzaki / blue_thermal_printer

Working with thermal printer via bluetooth (Flutter)
MIT License
164 stars 205 forks source link

Exception when trying to connect printer using blue_thermal_printer package #119

Closed JoyceMassau closed 2 years ago

JoyceMassau commented 2 years ago

Dear Kakzaki,

Thank you for creating this package, I was looking for one that would suit me in this functionality

It turns out that it works fine for listing the available printers, however the Console gives me an error when I click to connect a printer, making it impossible to connect the printer and consequently be able to print:

W/BluetoothAdapter(18780): getBluetoothService() called with no BluetoothManagerCallback
E/BThermalPrinterPlugin(18780): read failed, socket might closed or timeout, read ret: -1
E/BThermalPrinterPlugin(18780): java.io.IOException: read failed, socket might closed or timeout, read ret: -1
E/BThermalPrinterPlugin(18780): at android.bluetooth.BluetoothSocket.readAll(BluetoothSocket.java:772)
E/BThermalPrinterPlugin(18780): at android.bluetooth.BluetoothSocket.readInt(BluetoothSocket.java:786)
E/BThermalPrinterPlugin(18780): at android.bluetooth.BluetoothSocket.connect(BluetoothSocket.java:404)
E/BThermalPrinterPlugin(18780): at id.kakzaki.blue_thermal_printer.BlueThermalPrinterPlugin.lambda$connect$0$BlueThermalPrinterPlugin(BlueThermalPrinterPlugin.java:357)
E/BThermalPrinterPlugin(18780): at id.kakzaki.blue_thermal_printer.-$$Lambda$BlueThermalPrinterPlugin$5PttsFOLL4334Mu9cVZiR79reKY.run(Unknown Source:6)
E/BThermalPrinterPlugin(18780): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
E/BThermalPrinterPlugin(18780): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
E/BThermalPrinterPlugin(18780): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
E/BThermalPrinterPlugin(18780): at java.lang.Thread.run(Thread.java:919)

I'm currently using blue_thermal_printer in version 1.1.5 and Flutter in version 2.2.2, with Dart in version 2.13.3

I saw previous issues that reported this situation, but they reported being something related to the version of Flutter and the blue_thermal_printer package, but I tried to downgrade Flutter to use version v1.5.4-hotfix.2, [as mentioned here](https://github.com /kakzaki/blue_thermal_printer/issues/5) and the problem persisted when pressing the printer connection button

Code excerpt that results in the error:

Future<void> _conectaImpressora() async {
    if (_impressora == null) {
      _mensagemSnackbar.currentState.showSnackBar(
        SnackBar(
          content: Text('Nenhuma impressora selecionada.'),
        ),
      );
    } else {
      await bluetooth.isConnected.then((foiConectado) {
        if (!foiConectado) {
          bluetooth.connect(_impressora).catchError((error) {
            setState(() => _conectado = false);
          });
          setState(() => _conectado = true);
        }
      });
    }
  }

Really appreciate for your help.

yithanglee commented 2 years ago

same here

ravi2143 commented 2 years ago

is it resolved same problem here

masdaagus commented 2 years ago

i face the same problem in andoird 11

yithanglee commented 2 years ago

in the end i downgrade my flutter and downgrade the package to work.

masdaagus commented 2 years ago

in the end i downgrade my flutter and downgrade the package to work.

what flutter version its gonna work ?

yithanglee commented 2 years ago

flutter 2.8.0

github-actions[bot] commented 2 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

muhd-ameen commented 1 year ago

in the end i downgrade my flutter and downgrade the package to work.

downgraded package version?