-
Notifications
You must be signed in to change notification settings - Fork 479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App launches but immediately freezes and crashes #197
Comments
Hi @ShadowStacker, This is probably a permission issue, in the log you provided there is a line where it says "java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT". Try to define the needed android permissions in your android/app/main/AndroidManifest.xml before the application tag (if that doesnt work, try defining the following in the debug manifest too);
|
Thanks for the reply! I had already added those lines to my AndroidManifest.xml file, I don't have a debug manifest. I created a new folder in src and named it "debug" and copied the manifest file into it but I have the same error log and same behavior of the app freezing. |
try to run the following command into your project android folder:
Also, what flutter version are you using? |
AFAIK I am running the latest version of Flutter in VS Code. |
Generally when something goes wrong in my projects after a new package/library installation or configuration change the first thing i do is to run the gradlew utility that resides in the android folder of the project with the clean option, generally you cd into the android folder of your project and run the "gradlew clean" command, that will try to clean some old configuration of your project, always good to try. Also, you will be using the ESP32 with bluetooth low energy or serial to communicate with the app? This package only works with serial communication if i'm not wrong, so if you're planning to use the low energy counterpart i would use something like this package that works for BLE. Another thing you can try is to run the example project of this package to see if there's something wrong with your project. |
Sorry I meant to say serial instead of BLE, but I may switch over to BLE because this is a hassle. I still dont understand how to run commands within VS code, other than ctrl-shift-p. |
In VSCode you can run commands through the integrated terminal, you can also run the commands through your native OS terminal, cmd in windows or the terminal in linux. Honestly i think that the first thing you should do is to run the example project i said earlier, just to make sure that there is nothing wrong with your setup. I'm also currently using this package to develop a app that uses serial communication from a buetooth device, but i'm using flutter 3.0, maybe the current version of flutter has some kind of problem with this package since it's not updated in a while. |
The example project is what I am trying to run, in fact I am using a slightly updated version hosted here: https://github.com/pst9354/flutter_bluetooth_serial Edit: When running gradlew clean from windows Command Prompt in the Arduino folder I get this out:
|
In that case the project is created by you or you downloaded the source code of this package? If you want to run the command for the example project of this package you should run the gradlew command inside the android folder from the example folder, something like this:
Now, if the project you created happens to have the same name from this package i would run the |
Trying to run the example from 0.4.0 on my Pixel 5a running whatever the latest flavor of android is available for it and I get this Debug Output:
Launching lib\main.dart on Pixel 5a in debug mode... main.dart:1 Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01 Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01 Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01 √ Built build\app\outputs\flutter-apk\app-debug.apk. V/FlutterBluetoothSerial(23048): Attached to engine I/thserialexample(23048): Compiler allocated 4413KB to compile void android.view.ViewRootImpl.performTraversals() Connecting to VM Service at ws://127.0.0.1:64348/Gcsxj9xW4x4=/ws E/MethodChannel#flutter_bluetooth_serial/methods(23048): Failed to handle method call E/MethodChannel#flutter_bluetooth_serial/methods(23048): java.lang.SecurityException: Need android.permission.BLUETOOTH_CONNECT permission for android.content.AttributionSource@5da1dd98: getName E/MethodChannel#flutter_bluetooth_serial/methods(23048): at android.os.Parcel.createExceptionOrNull(Parcel.java:3011) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at android.os.Parcel.createException(Parcel.java:2995) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at android.os.Parcel.readException(Parcel.java:2978) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at android.os.Parcel.readException(Parcel.java:2920) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at android.bluetooth.IBluetoothManager$Stub$Proxy.getName(IBluetoothManager.java:555) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at android.bluetooth.BluetoothAdapter.getName(BluetoothAdapter.java:1552) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at io.github.edufolly.flutterbluetoothserial.FlutterBluetoothSerialPlugin$FlutterBluetoothSerialMethodCallHandler.onMethodCall(FlutterBluetoothSerialPlugin.java:727) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$DartMessenger(DartMessenger.java:322) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at io.flutter.embedding.engine.dart.-$$Lambda$DartMessenger$2j2MERcK825A5j1fv5sZ7xB2Iuo.run(Unknown Source:12) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at android.os.Handler.handleCallback(Handler.java:942) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at android.os.Handler.dispatchMessage(Handler.java:99) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at android.os.Looper.loopOnce(Looper.java:201) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at android.os.Looper.loop(Looper.java:288) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at android.app.ActivityThread.main(ActivityThread.java:7884) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936) E/MethodChannel#flutter_bluetooth_serial/methods(23048): Caused by: android.os.RemoteException: Remote stack trace: E/MethodChannel#flutter_bluetooth_serial/methods(23048): at com.android.server.bluetooth.BluetoothManagerService.checkPermissionForDataDelivery(BluetoothManagerService.java:3248) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at com.android.server.bluetooth.BluetoothManagerService.checkConnectPermissionForDataDelivery(BluetoothManagerService.java:3266) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at com.android.server.bluetooth.BluetoothManagerService.getName(BluetoothManagerService.java:1942) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at android.bluetooth.IBluetoothManager$Stub.onTransact(IBluetoothManager.java:258) E/MethodChannel#flutter_bluetooth_serial/methods(23048): at android.os.Binder.execTransactInternal(Binder.java:1280) E/MethodChannel#flutter_bluetooth_serial/methods(23048): W/FlutterBluePlugin(23048): Local Bluetooth MAC address is hidden by system, trying other options... D/FlutterBluePlugin(23048): Trying to obtain address using Settings Secure bank D/FlutterBluePlugin(23048): Obtaining address using Settings Secure bank failed D/FlutterBluePlugin(23048): Trying to obtain address using reflection against internal Android code W/thserialexample(23048): Accessing hidden field Landroid/bluetooth/BluetoothAdapter;->mService:Landroid/bluetooth/IBluetooth; (unsupported, reflection, allowed) W/thserialexample(23048): Accessing hidden method Landroid/bluetooth/IBluetooth$Stub$Proxy;->getAddress()Ljava/lang/String; (unsupported, reflection, allowed) D/FlutterBluePlugin(23048): Obtaining address using reflection against internal Android code failed D/FlutterBluePlugin(23048): Trying to look up address by network interfaces - might be invalid on some devices D/CompatibilityChangeReporter(23048): Compat change id reported: 170188668; UID 10347; state: ENABLED W/FlutterBluePlugin(23048): Looking for address by network interfaces failed E/SurfaceSyncer(23048): Failed to find sync for id=0 W/Parcel (23048): Expecting binder but got null! E/OpenGLRenderer(23048): Unable to match the desired swap behavior. E/SurfaceSyncer(23048): Failed to find sync for id=0 E/SurfaceSyncer(23048): Failed to find sync for id=1 Lost connection to device. Exited (sigterm)
The text was updated successfully, but these errors were encountered: