Flutter app crashes on hot restart only on iOS Simulator - flutter

Not sure what is going on, but when I hot restart my flutter app crashes using iOS simulator. Hot restart works fine on an Android simulator. I even tried to uninstall and install XCode again.
Here is what gets printed on the terminal
[ +459 ms] Hot restart performed in 924ms.
[ +3 ms] Restarted application in 936ms.
[ +900 ms] Service protocol connection closed.
[ ] Lost connection to device.
[ +3 ms] DevFS: Deleting filesystem on the device (file:///Users/frederickmfinanga/Library/Developer/CoreSimulator/Devices/775342AF-E52F-46EB-9CDB-9C29720FC357/data/Containers/Data/Application/D093EF45-D895-481C-B965-CA56F7881A5C/tmp/the_hair_routinenSBAWo/the_hair_routine/)
Failed to send request: {"jsonrpc":"2.0","id":"46","method":"getMemoryUsage","params":{"isolateId":"isolates/4165970133496907"}}
[ +257 ms] Ignored error while cleaning up DevFS: TimeoutException after 0:00:00.250000: Future not completed
[ +1 ms] "flutter run" took 646,839ms.
[ +259 ms] ensureAnalyticsSent: 242ms
[ +1 ms] Running shutdown hooks
[ ] Shutdown hook priority 4
[ ] Shutdown hooks complete
[ ] exiting with code 0

I had the same issue. After two days of debugging I have just found out it was caused by one of my dependencies. It is firebase_auth package version 1.1.3.
As I can see the issue is resolved in firebase_auth 1.1.4 released on 10th of May 2021.
So just update to firebase_auth 1.1.4 if you use this package

I faced something similar a few days back.
There can be two possibilities why it is happening :
You have not granted permission for something you are trying to access (like getting the location/camera ). If this is the case then read the docs of the package you might be using and add the permissions programatically.
Sometimes our podfile reference gets corrupted. (This is what happened in my case). For this delete your podfile.lock file (ios/podfile.lock). For a fresh start you can also delete your pubspec.lock as well. And then do a flutter pub get or simply run your app.

Related

Flutter run waiting for connection from debug service on chrome

I use flutter on window 10, when i run flutter on console and perform flutter run -d chrome, the error is waiting for connection from debug service on chrome. The error from chrome page show "The connection cant be reach".
My flutter doctor show i didnt install Visual Studio, but i already used to the Visual Studio Code. Is it a must to install Visual Studio ? Other than that, everything is passed.
I try to run the app on Visual Studio Code, the error is the same. Even on edge, on web-server. The error is the same.
I try to add Dart Debug Extension on Chrome but cannot be enable. Can some help ?
My flutter run -d chrome --verbose show below :
[tag:C:\Users\Administrator\myflutter_app>flutter run -d chrome --verbose
[ +10 ms] <- compile org-dartlang-app:/web_entrypoint.dart
[+19685 ms] Waiting for connection from debug service on Chrome... (completed in 20.0s)
[ +2 ms] Synced 30.6MB.
[ +1 ms] <- accept
[ ] Caching compiled dill
[+2477 ms] [CHROME]:
[ +18 ms] [CHROME]: DevTools listening on ws://127.0.0.1:57469/devtools/browser/51db6ac9-54b7-4fb7-bdb4- 25fb1707d9d6]
The problem can be solved by performing the following actions
Upgraded flutter to latest version
Reinstall android studio
run flutter pub upgrade --major-versions
upgrade your chrome to latest
if you are using any extension in VS code to run flutter then there is also a possibility that the extension is not working properly try to change the version.
If it works give me a upvote,I'm new here.

How to use --status for details when starting a gradle daemon via flutter build (slow connection)

I am running flutter build apk --verbose and I am on a slow and unreliable Internet connection.
I already had issues with gradle downloading 10 times, which I was able to solve by downloading the ZIP manually and setting distributionUrl=gradle-6.7-all.zip
Now I am stuck at
[ +94 ms] Starting a Gradle Daemon, 1 stopped Daemon could not be reused, use --status for details
How can I pass the --status flag to see what is actually happening?
flutter build does not accept this flag
I believe it tries to download from Maven, because I see error message when the connection is disconnected. But a progress indicator would be nice.

Flutter app crashes before integration tests start (chrome)

I am having an issue in experimenting with flutter integration tests. My goal is to be able to run headless tests for training purposes (a student produces an app, that I will test automatically). As it runs on servers it has to be headless and as quick as possible, so I chose chromedriver (I am not sure this is the best choice though, if you have other ideas please feel free to tell me).
I followed the tutorial here: https://flutter.dev/docs/cookbook/testing/integration/introduction
I created an empty project, filled lib/main.dart, test_driver/app.dart, test_driver/app_test.dart and pubspec.yaml exactly as suggested on the link above.
Then I tried to run this command:
flutter drive --target=test_driver/app.dart
Everything works properly, all tests passed
Then I launched chromedriver with chromedriver --port=4444 and tried to launch the test on chrome as suggested in the tutorial:
flutter drive test_driver/app.dart --browser-name=chrome --release
In this situation, after some time chrome opens and immediately crash ("Application finished"), juste before app_test.dart is launched:
Running "flutter pub get" in test_simple... 657ms
Launching test_driver/app.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome... 17,1s
This app is linked to the debug service: ws://127.0.0.1:33437/_FLIixzh_w0=/ws
Debug service listening on ws://127.0.0.1:33437/_FLIixzh_w0=/ws
💪 Running with sound null safety 💪
Application finished.
00:00 +0: Counter App (setUpAll)
Then the tests hang here forever until I kill it manually. Adding the "-v" flag does not give more information on why the application itself has finished:
[ +23 ms] Running "flutter pub get" in test_simple... (completed in 828ms)
[ +172 ms] Generating /home/bolgar/StudioProjects/test_simple/android/app/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
[ +90 ms] Launching test_driver/app.dart on Chrome in debug mode...
[ +125 ms] Updating assets
[ +99 ms] Waiting for connection from debug service on Chrome...
[ +102 ms] <- reset
[ +5 ms] /home/bolgar/snap/flutter/common/flutter/bin/cache/dart-sdk/bin/dart --disable-dart-dev /home/bolgar/snap/flutter/common/flutter/bin/cache/artifacts/engine/linux-x64/frontend_server.dart.snapshot
--sdk-root /home/bolgar/snap/flutter/common/flutter/bin/cache/flutter_web_sdk/ --incremental --target=dartdevc --debugger-module-names --experimental-emit-debug-metadata -DFLUTTER_WEB_AUTO_DETECT=true
--output-dill /tmp/flutter_tools.KSIJUI/flutter_tool.EKPQRL/app.dill --libraries-spec file:///home/bolgar/snap/flutter/common/flutter/bin/cache/flutter_web_sdk/libraries.json --packages
/home/bolgar/StudioProjects/test_simple/.dart_tool/package_config.json -Ddart.vm.profile=false -Ddart.vm.product=false --enable-asserts --track-widget-creation --filesystem-root
/home/bolgar/StudioProjects/test_simple/test_driver --filesystem-root /home/bolgar/StudioProjects/test_simple/test --filesystem-root /tmp/flutter_tools.KSIJUI/flutter_tools.XZNNYT --filesystem-scheme
org-dartlang-app --initialize-from-dill build/b1b715402d823b7fd5c2b68d2edcb2ce.cache.dill.track.dill --platform
file:///home/bolgar/snap/flutter/common/flutter/bin/cache/flutter_web_sdk/kernel/flutter_ddc_sdk_sound.dill --sound-null-safety
[ +8 ms] <- compile org-dartlang-app:/web_entrypoint.dart
[+15724 ms] Waiting for connection from debug service on Chrome... (completed in 15,8s)
[ ] Synced 30.4MB.
[ ] <- accept
[ ] Caching compiled dill
[ +73 ms] Using Google Chrome 93.0.4577.63
[ +491 ms] [CHROME]:
[ ] [CHROME]:DevTools listening on ws://127.0.0.1:45213/devtools/browser/359be11c-4ac2-4ec0-b7ff-4fb67b69bf85
[ +169 ms] DwdsInjector: Received request for entrypoint at http://localhost:36257/main_module.bootstrap.js
[ +4 ms] MetadataProvider: Loading debug metadata...
[ +11 ms] MetadataProvider: Loaded debug metadata (sound null safety)
[ +5 ms] DwdsInjector: Injected debugging metadata for entrypoint at http://localhost:36257/main_module.bootstrap.js
[+1576 ms] ChromeProxyService: Initializing expression compiler for main_module.bootstrap.js with sound null safety: true
[ +47 ms] DevHandler: Debug service listening on ws://127.0.0.1:39027/zQL0xCzGkSU=/ws
[ +15 ms] This app is linked to the debug service: ws://127.0.0.1:39027/zQL0xCzGkSU=/ws
[ +4 ms] Debug service listening on ws://127.0.0.1:39027/zQL0xCzGkSU=/ws
[ ] 💪 Running with sound null safety 💪
[ +522 ms] Application finished.
[ +27 ms] DevHandler: Stopped debug service on ws://127.0.0.1:38021
[ +355 ms] executing: /home/bolgar/snap/flutter/common/flutter/bin/cache/dart-sdk/bin/dart /home/bolgar/StudioProjects/test_simple/test_driver/app_test.dart -rexpanded
[+1584 ms] 00:00 +0: Counter App (setUpAll)
[ +180 ms] DwdsInjector: Received request for entrypoint at http://localhost:36257/main_module.bootstrap.js
[ ] MetadataProvider: Loading debug metadata...
[ +6 ms] MetadataProvider: Loaded debug metadata (sound null safety)
[ +2 ms] DwdsInjector: Injected debugging metadata for entrypoint at http://localhost:36257/main_module.bootstrap.js
[+104632 ms] DwdsInjector: Received request for entrypoint at http://localhost:36257/main_module.bootstrap.js
[ ] MetadataProvider: Loading debug metadata...
[ +6 ms] MetadataProvider: Loaded debug metadata (sound null safety)
[ +2 ms] DwdsInjector: Injected debugging metadata for entrypoint at http://localhost:36257/main_module.bootstrap.js
Can anyone help me here on how to debug this situation ? I must admit that I am stuck.
Thanks a lot,
PS: I would also like to output the results of the drive test in JSON format, as you do with flutter test --machine ..., but I can't find a way to do it with flutter drive ..., so if anyone has a clue please tell me, otherwise I will open another post.

Flutter: Gradle failed when trying to built app

Gradle always get stucked for more than 10 minutes when I build
Here are the logs
+2671 ms] FAILURE: Build failed with an exception.
[ +98 ms] * What went wrong:
[ +1 ms] Gradle could not start your build.
[ +3 ms] > Could not create service of type ChecksumService using
BuildSessionScopeServices.createChecksumService().
[ +7 ms] > Cannot lock checksums cache (/home/pavan/new_project/android/.gradle/checksums) as
it has already been locked by this process.
It's probably related to your cache.
If you're using a Windows OS, clear your .lock cache in this directory (search .lock in the directory itself and remove everything with a .lock extension deleted):
C:\Users<your username>.gradle\caches
If you got a Linux:
/home/ your username /.gradle/caches
If you've got a Mac:
/Users/ your username /.gradle/caches
On Windows 10, I deleted all .lock files located in .gradle directory AFTER having restarted my pc !

Only Flutter web relese build does not work

When I run the Flutter web app in Android Studio using the run button or by flutter run -d Chrome, everything works just fine.
When I run flutter build web and open $(project_dir)/build/web/index.html, I get a white screen. There are these errors in the browser console:
Failed to load app from a service worker. Falling back to plain <script> tag. index.html:85:21
Loading failed for the <script> with source “file:///main.dart.js”. index.html:1:1
When I run flutter build web -v there is following:
[ +68 ms] Skipping target: web_entrypoint
[ +1 ms] Skipping target: gen_localizations
[ +311 ms] Skipping target: dart2js
[ +10 ms] invalidated build due to missing files:
/home/vanousek/prg/substance-mix/DOES_NOT_EXIST_RERUN_FOR_WILDCARD954977783
[ +72 ms] web_release_bundle: Starting due to {InvalidatedReasonKind.inputMissing: The following inputs were
missing: /home/vanousek/prg/substance-mix/DOES_NOT_EXIST_RERUN_FOR_WILDCARD954977783,
InvalidatedReasonKind.inputChanged: The following inputs have updated contents:
/home/vanousek/prg/substance-mix/build/web/main.dart.js,build/web/index.html}
[ +121 ms] Manifest contained wildcard assets. Inserting missing file into build graph to force rerun. for
more information see #56466.
When building your flutter app for web it's intended to be run on a web server.
Running flutter build web, would compile the project into a web project. You can use web hosting providers such as netify, firebase hosting, and Github pages.
Running the ./build/web/index.html would not show up. That's why you got the errors in the console.
You could run flutter run --release -d chrome to run on Chrome in release mode.
EDIT:
This is chrome DevTools, it seems that the site was looking for the main.dart.js and other resources.
I noticed it was pointing towards https://your_url/main.dart.js but the resource is located in https://your_url/substance_mix/main.dart.js. So it threw 404's.
One solution to this is to edit the index.html and add /substance-mix/ to all resources. Eg. change scriptTag.src = 'main.dart.js'; to scriptTag.src = 'substance_mix/main.dart.js';
or you can the GitHub Pages configurations. And have your website directly on https://mikulasvanousek.github.io/