9

I have a Android/iOS app developed using Flutter through Visual Studio Code. When I run it on Android >=5.0 or any version of iOS it works flawlessly, however it crashes immediately when I run it on Android 4.x (Unfortunately, app has stopped).

I want to fix it, but Flutterdoesn't show me what is happening.

I tried to run through VSCode pushing F5 button and also using command line flutter run, but neither shows me something that I could work with. I tried to run with trace command [Flutter trace run], but it says The --debug-port argument must be specified and I don't know what it means.

I just need a stacktrace or a line error showing me what is the problem. Do I have to configure something on VSCode?

Notheros
  • 2,137
  • 9
  • 23
  • 34
  • 1
    For Flutter code you can use https://github.com/flutter/sentry. For iOS you can try https://github.com/flutter/flutter/issues/20998#issuecomment-418845807 for Android running `adb logcat` while the app is run should provide more details. – Günter Zöchbauer Jan 21 '19 at 12:22
  • 1
    You could work around it, and read the logs directly from the device with the command `adb logcat` https://developer.android.com/studio/command-line/logcat – Blundell Jan 21 '19 at 12:22
  • Thanks Günter and Blundell! Using logcat I found `Exception thrown during pause android.os.DeadObjectException`. No idea how to fix it, but now I can work with it. – Notheros Jan 21 '19 at 13:09
  • For android you can type in the terminal `cd android` and then `./gradlew build --stacktrace` – Elmer Jan 03 '20 at 08:59
  • Does this answer your question? [How do you get the current stacktrace in Dart for a Completer.CompleteException(exception, stackTrace);](https://stackoverflow.com/questions/13963837/how-do-you-get-the-current-stacktrace-in-dart-for-a-completer-completeexception) – kris Mar 15 '20 at 02:04
  • You can use `StackTrace.current` - I think this question is a duplicate of this : https://stackoverflow.com/questions/13963837/how-do-you-get-the-current-stacktrace-in-dart-for-a-completer-completeexception - either way, the answer I have given is there. – kris Mar 15 '20 at 02:06

2 Answers2

2

There's a Debug Console available in Visual Studio Code as per checking version 1.51.1. This can be enabled/disabled by navigating through the menu View > Debug Console. Both logs from Android emulator and iOS simulator can be displayed on the Debug Console.

However, if you're looking into checking Flutter debug logs outside of Visual Studio Code, the adb logcat command using the terminal works well for Android as previously mentioned in the comments.

On iOS, one way of checking the logs is through the Console. Press ⌘ + space and type "Console", and press Enter to launch the app. The iOS device should be displayed on the left-side pane of the Console app under Devices. Clicking on the iOS device should display its logs.

Omatt
  • 8,564
  • 2
  • 42
  • 144
0

Run the app with flutter run --verbose in the console and you'll get the complete stack trace.

Antonio Brandao
  • 1,353
  • 13
  • 19