Closed arkanmgerges closed 4 weeks ago
Hi @arkanmgerges, your sample contains some third_party packages and custom widget definitions, please provide a sample without any third party packages and if possible, provide the custom widget definition.
Although, from this piece of code, I can see that you're using the Expanded
widget incorrectly, that may be the cause of the issue, although, I do find it strange that it wasn't reported in debug mode.
Align(
alignment: Alignment.topLeft,
child: Expanded(child:CustomElevatedButton(callback: () {}, text: S.of(context).dailyCheck.sentenceCase, fillSpace: true)),
),
Hi @danagbemava-nc, and thanks for the reply. Let's suppose that my code is totally wrong, and this is not the point, I don't only want to fix my issue, but the problem is why in the debug mode does not show errors? This can be a nightmare for the developer (my personal opinion), as I develop a large app in the debug mode, and no errors shown (usually I'm using it without -v option), and when we want to use the release mode, errors can appear in the console. This is really bad (as for now in my knowledge until maybe someone can explain this behavior and how to deal with such situation)
@arkanmgerges, I agree that it is strange which is why I made this statement.
although, I do find it strange that it wasn't reported in debug mode.
Which is why I need your full sample so that it can be properly investigated.
Kindly provide the the CustomElevatedButton
so I can see if it can be sufficiently reproduced and the appropriate actions taken.
Thank you
@danagbemava-nc Thank you for your reply. I will prepare a new project and I will try to make it have the same issue and provide it for the investigation.
Hi @danagbemava-nc , I've created a new app with the issue successfully, and compressed it into zip file, you can download it from my google drive
I've tested it on my physical phone (Samsung Galaxy Note 10+), using the usb cable. and I tried the debug and release mode. In debug mode there is no error and the page will appear, while in release mode the gray screen will appear and the error messages will appear,
Thank you
This is rather strange, when I run it in debug mode, I immediately got the error in the console. See attached logs.
verbose logs
log.txt
normal logs
normal.txt
I'm using Android studio
And all the logs are in the "Run" window bellow as shown:
Also my device specification is:
I ran the app (bug_app) in VSCode and I can see the error in the DEBUG CONSOLE
I don't know why I can not see this in Android Studio
I just tried with Android Studio and I got the error.
I do find it very strange that you're not getting the error.
Thank you @danagbemava-nc for letting me know, I will reinstall Android Studio, and let you know
Strange, the same thing, no error shown after reinstalling Android Studio, also I'm using my physical phone (Samsung Galaxy Note 10+)
@arkanmgerges can you test with any other device to see if you still experience this issue? I don't believe that it could be an issue with your device, but this is a rather strange issue.
@danagbemava-nc It is the same, no errors
With that same emulator, does it produce the error in vscode
?
In VSCode I can see the error
@danagbemava-nc finally I solved the issue (by reading this page on overstack), I've reset Android Studio to the default settings, then I installed Dart and Flutter plugins, then It worked
Manage IDE Settings ---> Restore Default Settings...
Thank you @danagbemava-nc for your help
@danagbemava-nc If you include the --machine
option on the command line the error is not generated.
flutter run --machine
@stevemessick, thanks for pointing that out, I can reproduce that.
@DanTup
Sorry for the ping, don't know who the right person is. Can flutter daemon
add a new event that reports these errors? Or is there a better solution to get these errors?
I am writing a plugin for a text editor and without error reporting it would be quite useless.
For context:
@Waqar144 I'm not sure I understand the request. flutter daemon
is used for managing devices and (IMO) it doesn't make sense to send any build/runtime errors there in my opinion.
If you're writing an editor plugin to run Flutted debug sessions I would expect you to run the app using flutter run --machine
and these errors to show up in the output there (this is where VS Code is getting them - via the debug adapter).
However, if your editor supports the Debug Adapter Protocol, you may be able to avoid writing code to handle this yourself.. You could start a Flutter debug adapter using flutter debug-adapter
and then you may get full debug support for free (the VS Code extension is using this debug adapter).
@Dantup thanks for replying.
I am using flutter run --machine
indeed, I just referred to it as flutter daemon because the docs about the protocol live under that name. The exception errors however don't show up and that is the main issue.
Thanks about the DAP hint, I will look into that. Our DAP implementation is too generic atm, so we will need to handle custom requests.
@Waqar144 if you can reproduce an issue where flutter run --machine
is not providing you with an error you expect, please open a new issue with a sample project - that sounds like a bug. Off the top of my head, I'm wondering if it might be related to structured errors being on by default (which means they're only going over the VM Service).
Our DAP implementation is too generic atm, so we will need to handle custom requests.
Ah yes, you would need the ability to use custom requests for some functionality - I do think it'd be better overall to build on DAP than flutter run --machine
though - you won't (assuming your DAP client supports them) need to build your own support for things like breakpoints/evaluation, and it'll also protect you from many kinds of SDK changes that DAP has abstracted away.
@DanTup
Off the top of my head, I'm wondering if it might be related to structured errors being on by default (which means they're only going over the VM Service).
Ah, that was it. I disabled them by adding the following argument
--dart-define=flutter.inspector.structuredErrors=false
and now everything is reported as expected. Thanks a lot for helping. And I think this issue can be closed.
Overall going the DAP route seems like a more sensible thing to do.
Yep, using DAP this wouldn't be an issue as the debug adapter would have received the structured errors events over the VM Service and converted them to output events.
Reading the comments above, I think this is probably working as intended - I expect that flutter run
is printing the errors itself because it's intended to be used by a user in a terminal, but for flutter run --machine
, the client running the process is expected to listen for the Flutter.Error
events and present them to the user in an appropriate way (which may or may not be in the console).
I'm not sure why it wasn't showing up for @arkanmgerges until they reset the settings in Android Studio, but unless anyone is still seeing this behaviour (the errors not being visible in Android Studio, not that they don't show up if you run --machine
manually from a terminal) so it can be debugged further, I suggest we close it (@danagbemava-nc ?)
I'll be closing this based on https://github.com/flutter/flutter/issues/92903#issuecomment-2372022097. If there's anything more to report, please leave a comment below and I will reopen this.
Thank you
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.
Steps to Reproduce
I'm working on an app, and it breaks on a page in release mode, but it works in debug mode (there is no error in logs when it is in debug mode)
Note: The code is identical for both release and debug modes
Expected results: If there is an error it should show it in logs in debug mode
Actual results: Error in release mode
Logs
[Gist - logs in debug mode](https://gist.github.com/arkanmgerges/2c0bbeb4a202c2c53849cd6bd1a29951) [Gist - logs in release mode](https://gist.github.com/arkanmgerges/9157eb703a04530953db32bb7b79dce5) **Flutter Analyze** ``` Analyzing cafm... info - Unused import: 'package:flutter/foundation.dart' - lib\data\model\project.dart:2:8 - unused_import info - The value of the local variable 'st' isn't used - lib\main.dart:45:9 - unused_local_variable info - Unused import: 'package:cafm/data/provider/exception/unauthorized_exception.dart' - lib\presentation\screen\app_settings_screen.dart:1:8 - unused_import info - Unused import: 'package:cafm/logic/cubit/auth_cubit.dart' - lib\presentation\screen\app_settings_screen.dart:4:8 - unused_import info - Unused import: 'package:flutter_bloc/flutter_bloc.dart' - lib\presentation\screen\app_settings_screen.dart:6:8 - unused_import info - Unused import: 'package:cafm/di/app_di.dart' - lib\presentation\screen\technician_login_screen.dart:3:8 - unused_import info - Unused import: 'package:cafm/data/model/technician.dart' - test\data\model\person_test.dart:4:8 - unused_import info - The value of the local variable 'appState' isn't used - test\data\model\person_test.dart:10:14 - unused_local_variable info - Unused import: 'package:bloc_test/bloc_test.dart' - test\logic\cubit\app_state_test.dart:3:8 - unused_import info - Unused import: 'package:bloc_test/bloc_test.dart' - test\logic\cubit\counter_cubit_test.dart:1:8 - unused_import info - Unused import: 'package:test/test.dart' - test\logic\cubit\counter_cubit_test.dart:3:8 - unused_import 11 issues found. (ran in 14.0s) ``` **Flutter Doctor** ```sh C:\Users\arkan\StudioProjects\cafm>flutter doctor -v [√] Flutter (Channel stable, 2.5.3, on Microsoft Windows [Version 10.0.19043.1320], locale en-US) • Flutter version 2.5.3 at C:\Users\arkan\dev\flutter\sdk • Upstream repository https://github.com/flutter/flutter.git • Framework revision 18116933e7 (3 weeks ago), 2021-10-15 10:46:35 -0700 • Engine revision d3ea636dc5 • Dart version 2.14.4 [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Users\arkan\AppData\Local\Android\sdk • Platform android-30, build-tools 30.0.3 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [√] Android Studio (version 2020.3) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189) [√] IntelliJ IDEA Ultimate Edition (version 2021.2) • IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA 2021.2 • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart [√] VS Code (version 1.61.2) • VS Code at C:\Users\arkan\AppData\Local\Programs\Microsoft VS Code • Flutter extension can be installed from: https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [√] Connected device (3 available) • SM N975F (mobile) • RF8MA1ALYDL • android-arm64 • Android 11 (API 30) • Chrome (web) • chrome • web-javascript • Google Chrome 95.0.4638.54 • Edge (web) • edge • web-javascript • Microsoft Edge 95.0.1020.40 • No issues found! ```