flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
165.02k stars 27.19k forks source link

Exceptions not being logged in Android Studio #84539

Open creativecreatorormaybenot opened 3 years ago

creativecreatorormaybenot commented 3 years ago

Problem

For about a week now, I have not been able to see any exceptions thrown in Dart code while running my Flutter app in Android Studio.

This problem is similar to https://github.com/flutter/flutter/issues/41133, however, I am running on Android. I have not been able to find any still open issue mentioning this issue on the latest version.

Detailed behavior

When I run any Flutter app, e.g.

Click to expand sample code ```dart void main() { runApp(const _TestWidget()); } class _TestWidget extends StatelessWidget { const _TestWidget({Key? key}) : super(key: key); @override Widget build(BuildContext context) { throw Exception('test'); return Container(); } } ```
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following _Exception was thrown building _TestWidget(dirty):
Exception: test

But no matter what I try, no exceptions are shown when the I use the normal run configuration inside of Android Studio.

Prints

This is the best part, all other prints and logging work perfectly fine. So when I insert a print('foo'), I see it in the console, but not the exceptions being thrown 🤷‍♀️

It seems the stderr is not connected to Android Studio's Run console.

Versions

Click to expand versions ``` [✓] Flutter (Channel stable, 2.2.2, on Microsoft Windows [Version 10.0.19041.1052], locale en-US) • Flutter version 2.2.2 • Framework revision d79295af24 (2 days ago), 2021-06-11 08:56:01 -0700 • Engine revision 91c9fc8fe0 • Dart version 2.13.3 [!] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Platform android-S, build-tools 30.0.2 [✓] Android Studio (version 4.1.0) • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174) [✓] Connected device (4 available) • sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) ```
TahaTesser commented 3 years ago

Hi @creativecreatorormaybenot Running on Windows environment (same as you), simply running the app in Android Studio, I do see the exception logs when running on the stable channel

minimal code sample ```dart import 'package:flutter/material.dart'; void main() { runApp(const _TestWidget()); } class _TestWidget extends StatelessWidget { const _TestWidget({Key? key}) : super(key: key); @override Widget build(BuildContext context) { throw Exception('test'); return Container(); } } ```
preview ![image](https://user-images.githubusercontent.com/48603081/121909328-7a606d80-cd36-11eb-9bdb-233585d57b8d.png)
flutter doctor -v ```console [✓] Flutter (Channel stable, 2.2.2, on Microsoft Windows [Version 10.0.19043.1055], locale en-US) • Flutter version 2.2.2 at C:\Users\Taha\Code\flutter_stable • Framework revision d79295af24 (3 days ago), 2021-06-11 08:56:01 -0700 • Engine revision 91c9fc8fe0 • Dart version 2.13.3 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Users\Taha\Code\SDK • Platform android-30, build-tools 30.0.3 • ANDROID_SDK_ROOT = C:\Users\Taha\Code\SDK • Java binary at: C:\Users\Taha\Code\openjdk\bin\java.exe • Java version OpenJDK Runtime Environment (build 1.8.0-262-b10) • All Android licenses accepted. [✓] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [✓] Visual Studio - develop for Windows (Visual Studio Community 2019 16.10.1) • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community • Visual Studio Community 2019 version 16.10.31402.337 • Windows 10 SDK version 10.0.19041.0 [!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions). [✓] IntelliJ IDEA Community Edition (version 2021.1) • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.1.1 • Flutter plugin version 57.0.5 • Dart plugin version 211.7233 [✓] VS Code (version 1.57.0) • VS Code at C:\Users\Taha\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.23.0 [✓] Connected device (4 available) • IN2011 (mobile) • c9d8ee0c • android-arm64 • Android 11 (API 30) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19043.1055] • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.101 • Edge (web) • edge • web-javascript • Microsoft Edge 91.0.864.48 ! Doctor found issues in 1 category. ```

image

Can make sure you're using the same plugin?

TahaTesser commented 3 years ago

@creativecreatorormaybenot Since it is working as expected, the issue seems to be solved when upgrading, which makes it a plugin issue rather than a Flutter issue. Closing, If you disagree, please write in the comments and I will reopen it. Thank you

creativecreatorormaybenot commented 3 years ago

I updated to the latest plugin version (57.0.2). Same behavior, errors not being displayed in Android Studio but when using flutter run from the terminal.

(edited to keep history cleaner)