Flutter Error when trying to debug Windows App - flutter

I am trying to start Windows app for first time with default Flutter Project but it's showing this error espacialy.
Unable to start engine without AOT data.
Failed to create view controller.
Error waiting for a debug connection: The log reader stopped unexpectedly, or never started.
Error launching application on Windows.
Exited (sigterm)
Here is my flutter doctor -v results:
[√] Flutter (Channel stable, 2.10.0, on Microsoft Windows [Version
10.0.19042.1526], locale tr-TR)
• Flutter version 2.10.0 at D:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5f105a6ca7 (2 weeks ago), 2022-02-01 14:15:42 -0800
• Engine revision 776efd2034
• Dart version 2.16.0
• DevTools version 2.9.2
[√] Android toolchain - develop for Android devices (Android SDK version
31.0.0)
• Android SDK at D:\sdk
• Platform android-31, build-tools 31.0.0
• ANDROID_HOME = C:\Users\pc\AppData\Local\Android\Sdk
• Java binary at: D:\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[X] Chrome - develop for the web (Cannot find Chrome executable at
.\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.0)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.1.32210.238
• Windows 10 SDK version 10.0.22000.0
[√] Android Studio (version 2020.3)
• Android Studio at D:\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)
[√] Connected device (2 available)
• sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API
30) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19042.1526]
[√] HTTP Host Availability
I tried flutter clean but it is not working. What can I do for this error?

I have fixed this issue from aceta-minophen on github
(https://github.com/flutter/flutter/issues/97086#issuecomment-1029963716)
aceta-minophen solution:
Found the app.so file in ..\build\windows
Copied the file and pasted it in ..\build\windows\runner\Debug\data
[UPDATE]
upgrading flutter to the last version should fix this:
RUN:
flutter upgrade

It seems that problem with this version of Visual Studio
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.0)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.1.32210.238
• Windows 10 SDK version 10.0.22000.0
Try to unintall Visual Studio Community 2022 and install Visual Studio Community 2019
With Visual Studio 2019 all works like a charm :)

I was getting some AOT error wile launching the windows app from vs code , so i downgraded visual studio 2022 to visual studio 2019 and it was working for me

A workaround that also allowed debugging:
edit <proj_dir>\windows\flutter\CMakeLists.txt to replace $<CONFIG> with Debug
There was a single occurrence, near the end of add_custom_command.
This was needed after upgrading VS 2022 to 17.1.0 (it worked fine with 17.0.6).
Windows support for the project was initially added with flutter create --platforms=windows .
VS bug: CMake->vcxproj regression in 17.1.0 when using $ in custom command.

Flutter 2.10.3 resolves this issue.

I stated a fix for the issue on the video here it was simply the app.so being in the wrong folder,
You can watch the video here with full details

Steps to Reproduce
Create a new application.
run flutter run -d windows --debug
Expected results: The build should success.
Actual results: Can't load AOT data from C:\Users\nieti\Desktop\flutter_application_1\build\windows\runner\Debug\data\app.so; no such file. Unable to start engine without AOT data. Failed to create view controller. Error waiting for a debug connection: The log reader stopped unexpectedly, or never started. Error launching application on Windows.
Logs
Did you manage to solve your issue? Im facing this exact issue but flutter doctor shows that everything is OK and Windows is listed on Connected Devices. Im on Flutter 2.10
Hey! I faced the same issue today and I solved this by doing the following:
Found the app.so file in ..\build\windows
Copied the file and pasted it in ..\build\windows\runner\Debug\data

This is a good workaround:
https://stackoverflow.com/a/71216391/9948598
I need to restore CMakeLists.txt to his original state before build for release, but the modified version let me work in debug mode.

I have another solution instead of uninstalling visual Studio 2022 version just modify the the settings inside installer and install the latest version of windows sdk i.e. win sdk 10(10.0.20348.0) and that will solve the problem of app.so hence the AOTdata not found problem

Related

Hot restart/reload not always working in flutter

I think it has something to do with this warning I keep getting from dart sdk
Socket error: FileSystemException: Directory watcher closed unexpectedly, path =
'c:\Users\Saad\OneDrive\Documents\Scripts\mutanafisun'
I searched for a solution for it but found none.
this is my flutter doctor
[√] Flutter (Channel stable, 3.0.5, on Active code page: 1252
Microsoft Windows [Version 10.0.19044.1826], locale en-US)
• Flutter version 3.0.5 at C:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision f1875d570e (4 weeks ago), 2022-07-13 11:24:16 -0700
• Engine revision e85ea0e79c
• Dart version 2.17.6
• DevTools version 2.12.2
Checking Java status is taking a long time...[√] Android toolchain - develop for Android
devices (Android SDK version 31.0.0)
• Android SDK at C:\Users\Saad\AppData\Local\Android\sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: C:\Program Files\Java\jdk-14\bin\java
• Java version Java(TM) SE Runtime Environment (build 14+36-1461)
• 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 Build Tools 2022 17.2.3)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
• Visual Studio Build Tools 2022 version 17.2.32526.322
• 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).
[√] VS Code (version 1.70.1)
• VS Code at C:\Users\Saad\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.46.0
This seems to be a bug in the current Dart/Flutter releases, however, it should not have any material affect on your app. You should be able to continue as normal:
When Flutter builds it modifies a lot of files on disk in a short space of time and this sometimes overflows the watcher and causes it to close. The server has code to handle this (it creates new watchers and reanalyzes from disk), however to resolve some other issues during the restart it creates some additional watchers which do not have error handling (and since the Flutter build may still be occurring, it's possible those will close for the same reason). It's not ideal that a Flutter build can touch enough files to overflow the watcher and require a restart like this, but I believe that's understood behaviour because the server has had to handle this before.
Here is a full discussion:
https://github.com/dart-lang/sdk/issues/49286
Also see confirmation that fix has been found but not yet released:
There is a bug in the current Dart/Flutter stable releases that can trigger this error during a build. [They] have recently fixed the issue in the Dart SDK, but it has not been released yet. The fix will show up in a future release of the Dart/Flutter SDK. Unfortunately [they] don't know of a temporary workaround.
https://github.com/Dart-Code/Dart-Code/issues/4077

Not able to debug desktop in flutter

I am trying to start Windows app for first time with default Flutter Project but it's showing this error,
Launching lib\main.dart on Windows in debug mode...
lib\main.dart:1
Can't load AOT data from {#project-path}\build\windows\runner\Debug\data\app.so; no such file.
Unable to start engine without AOT data.
Failed to create view controller.
Error waiting for a debug connection: The log reader stopped unexpectedly, or never started.
Error launching application on Windows.
Exited (sigterm)
here is my flutter doctor -v result:
[√] Flutter (Channel stable, 2.10.2, on Microsoft Windows [Version 10.0.19044.1526], locale en-IN)
• Flutter version 2.10.2 at C:\src\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 097d3313d8 (3 days ago), 2022-02-18 19:33:08 -0600
• Engine revision a83ed0e5e3
• Dart version 2.16.1
• DevTools version 2.9.2
[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\panth\AppData\Local\Android\sdk
X cmdline-tools component is missing
Run `path/to/sdkmanager --install "cmdline-tools;latest"`
See https://developer.android.com/studio/command-line for more details.
X Android license status unknown.
Run `flutter doctor --android-licenses` to accept the SDK licenses.
See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[√] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.0)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.1.32210.238
• Windows 10 SDK version 10.0.19041.0
[√] 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)
[√] VS Code (version 1.64.2)
• VS Code at C:\Users\panth\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.29.0
[√] VS Code, 64-bit edition (version 1.63.2)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.29.0
[√] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19044.1526]
• Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.102
• Edge (web) • edge • web-javascript • Microsoft Edge 98.0.1108.56
[√] HTTP Host Availability
• All required HTTP hosts are available
! Doctor found issues in 1 category.
Here is what i have already tried
copy paste app.so file from ./build/windows to ./build/windows/runner/Debug/data
this is an inefficient solution, since hot reload doesn't work.
downgrade visual studio to 2019
I tried to downgrade visual studio to 2019, and then deleted windows folder form root directory, then ran flutter clean and flutter create .. then started debug and this error happened
Launching lib\main.dart on Windows in debug mode...
lib\main.dart:1
Error waiting for a debug connection: The log reader stopped unexpectedly, or never started.
Error launching application on Windows.
Exited (sigterm)
so i uninstalled visual studio and installed 2022 version back.
Also tried flutter clean had no effect.
What can I do for this error?
This is a bug in the version of CMake shipped with the latest update to Visual Studio 2022. There is currently no good workaround other than using an earlier version of VS, but you can follow that issue for updates.
When you downgraded to Visual Studio 2019, did you simply delete Visual Studio 2022?
I found that when I simply deleted Visual Studio 2022, I had your same error. I had success by uninstalling then reinstalling "Desktop development with C++" from my Visual Studio 2019, followed by flutter clean and flutter run -d windows.
I have fixed from this github issue.flutter github issue

Unable to find bundled Java version. MacBook Air M1

I was using flutter on MacBook Pro with intel. It was working fine. Now I switch to MacBook Air with M1 chip. I get error Unable to find bundled Java version. How can I fix it pleas?
flutter doctor -v
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.2 20D64 darwin-arm, locale
en-KW)
• Flutter version 2.2.3 at /Users/mac/FlutterDev/flutter
• Framework revision f4abaa0735 (5 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/mac/Library/Android/sdk
• Platform android-31, build-tools 31.0.0
• Java binary at: /Library/Internet
Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
• Java version Java(TM) SE Runtime Environment (build 1.8.0_301-b09)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.5.1, Build version 12E507
• CocoaPods version 1.10.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[!] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• 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
✗ Unable to find bundled Java version.
• Try updating or re-installing Android Studio.
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 11.2 20D64 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.131
! Doctor found issues in 1 category.
I fix it by changing Contents folder location.
from
/Applications/Android Studio Preview.app/Contents/jre/Contents
to
/Applications/Android Studio Preview.app/Contents/jre/jdk/Contents
after close the android studio preview I face a problem with start it again.
but in general flutter doctor works with no Issues.
I had the same problem and solved it this way
cd /Applications/Android\ Studio.app/Contents/jre
ln -s /Library/Java/JavaVirtualMachines/jdk-16.0.1.jdk jdk
flutter doctor -v
enter image description here
I had the same problem a few days ago when I installed Android Studio for ARM64, I noticed that JDK from Oracle right now was running in x64. Looking in the web I found that you can install a native JDK for M1.
So basically the way that I found to solve your problem of the best way was installing JDK 15 arm64 from Azul
It improves a lot the compiler time for Android app's.
about ✗ Unable to find bundled Java version. • Try updating or re-installing Android Studio.
I have another environments. But you can think by use my answer.
In my opinion, you need to install JDK(Java development Kit).
If you can use Visual studio extensions or android studio plugin(i don't know mac environment), find Java extension pack for installation JDK(this is on visual studio)and install. You have to select JAVA Path correctly. If you select it on install process, you don't need to choose Path process individually. You can see this path on System variable Path as JAVA_HOME named automatically. not user path.
I hope your flutter is well
First of all, check what's going on with your JAVA_HOME:
echo $JAVA_HOME
I assume in your case you would already have it set correctly, so it should appear in a path like this (the jdk version may vary):
/Library/Java/JavaVirtualMachines/jdk-16.0.2.jdk/Contents/Home
If it the path looks the same (or same with different java version), and you have also checked "where java", "java -version" etc, to make sure that the terminal recognises your java well and there is no other obvious java issue, that means that the only thing you need to do is to run these commands:
cd /Applications/Android\ Studio.app/Contents/jre
ln -s ../jre jdk
ln -s "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin" jdk
Now if you run flutter doctor -v, you should see no java errors and something like this instead of the previous error:
• Java binary at: /Applications/AndroidStudio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165)
And no more errors :)
Hope this helps! It definitely solved the issue for me after switching to an M1 MacBook Air and upgrading the AndroidStudio to ArcticFox 2020.3.1 Patch 1).

Flutter, Visual studio code project stuck on Analyzing

I have a flutter project I can run with no problems using git terminal and flutter command: flutter run
but I have been facing this problem recently when I try to open the same project using visual studio code,
once vs code starts, It tries to analyze the project for dart code errors. the procedure usually takes a relatively short time (a minute or so) but now It takes forever and I don't know why.
I tried to do flutter clean on my project, but It did not solve it. also tried flutter pub get, still not solving the problem. It is very strange because this is only happening when using visual studio code to open that particular project.
here is a log of flutter doctor -v command :
C:\Users\Rami>flutter doctor -v
[√] Flutter (Channel beta, v1.15.17, on Microsoft Windows [Version 10.0.18363.720], locale en-US)
• Flutter version 1.15.17 at D:\Flutter\sdk
• Framework revision 2294d75bfa (4 weeks ago), 2020-03-07 00:28:38 +0900
• Engine revision 5aff311948
• Dart version 2.8.0 (build 2.8.0-dev.12.0 9983424a3c)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at D:\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_SDK_ROOT = D:\Android\sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] VS Code (version 1.43.2)
• VS Code at C:\Users\Rami\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.8.1
[√] Connected device (3 available)
• SM A520F • 192.168.8.80:5555 • android-arm64 • Android 8.0.0 (API 26)
• Chrome • chrome • web-javascript • Google Chrome 80.0.3987.162
• Web Server • web-server • web-javascript • Flutter Tools
• No issues found!
Your feedback is appreciated,
Thank you
I solved it like here. Enable dart.previewLsp in your settings.
Ctrl + , and enter dart.previewLsp.
Also the problem pops up when I code nested generic types. eg. Future<Either<X, Y>>.
I avoid this as much as possible. You just need to copy the type from another line or use a snippet. Or code it from inside out.
Update
It seems the problem is fixed in recent versions of Dart. Just update your dart installation. Or avoid empty type declarations in generics. eg, Future<List<>>
I know this is too late, but I believe this helps any one stuck with this problem. In my case this is due to a syntax error. I tried commenting most recently edited files and restarted VSCode then this annoying analyzing thing stopped.
Make sure you didn't declare any nested generics and didn't finish the line with your var name like mine
Analyzing for infinite time. 😞
Future<List<>>
Now we are good 😃
Future<List<int>> getMyListOfInt();
Happened to me after upgrading to latest Flutter version (1.20.0). Closing and restarting VSCode fixed it for me.
you can follow these steps. It's work for me
Turn Analyzer logs on and see on what file its slow/stuck, sometimes that file has syntax error that is not handled by analyzer properly (how to turn analyzer logs on).
First column in logs are your system's milliseconds since epoch.
Also enabling dart.previewLsp as mentioned by #loki would help.
Another also, double check that your are not out of memory, the analyzer could be very hungry!
This issue should be cache-related.
You could try removing(do a backup just in case) all visual studio cache-related folders here ~/library/caches, then restart VS and you should be good to go.
This is the naming convention for VS cache folders.
com.microsoft.VSCode
com.microsoft.VSCode.ShipIt

Flutter with VSCode shows not installed even though its installs

I just getting with flutter. I have installed it along created a project successfully.
But when I try to run it fails.
Below is the output with flutter doctor -v
PS C:\android-app\flutter-app\flutter_first_app> flutter doctor -v
[√] Flutter (Channel master, v0.5.5-pre.9, on Microsoft Windows [Version 10.0.16299.461], locale en-US)
• Flutter version 0.5.5-pre.9 at C:\android-app\flutter
• Framework revision 587569337e (7 hours ago), 2018-06-13 00:02:21 +0200
• Engine revision a328531402
• Dart version 2.0.0-dev.60.0.flutter-a5e41681e5
[!] Android toolchain - develop for Android devices (Android SDK 28.0.0)
• Android SDK at C:\Users\Sreyah Admin\AppData\Local\Android\Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.0
• ANDROID_HOME = C:\Users\Sreyah Admin\AppData\Local\Android\Sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
X Android license status unknown.
[√] Android Studio (version 3.1)
• Android Studio at C:\Program Files\Android\Android Studio
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b02)
[!] VS Code, 64-bit edition (version 1.24.0)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension not installed; install from
https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter
[√] Connected devices (1 available)
• XT1706 • HKE63YLL • android-arm • Android 6.0 (API 23)
I have installed the Flutter extension.
I tried uninstall and install a couple of time, but still the same result.
I think there are two issues here:
Doctor says you don't have the extension
Your project doesn't run
1 Doctor says you don't have the extension
This is a bug I've just fixed. Seems like VS Code may have started lower-casing the extension folders recently, and our test for them was case sensitive. The fix is in master but hasn't made the beta channel (as of 22nd June 2018).
Note: This check doesn't affect anything else, as long as the extension is installed this is just an issue with the doctor output.
2. Your project doesn't run
This is probably not related to the doctor output if you can see the extension in VS Code. You haven't included any info on the reason your app doesn't run (does it give an error? what do you see?) so it's hard to guess; but if you can provide that info I can take a stab.
If you haven't already, it's also worth running the project from the command line with flutter run to see if it works there, to see whether the issue is specific to VS Code or something else with your setup.
If if works from the command line then I would recommend opening an issue on GitHub for the Dart-Code repo with more information and we can track it down from there.
Open your VS Code if you have it installed, if not you can still install it from the link. Flutter internally use Dart language to build a mobile app. So you need to install this extension
Then open this link "https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter" to install this extension.
After the installation run your flutter doctor -v to confirm.