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/
Related
I have created a project with Unity-Vuforia for Flutter. build and it is very good for Android and IOS, but when I got the webGl build and Flutter also got the web by flutter build web --web-renderer canvaskit -t lib/main.dart, and run, it stays in Loading and does nothing. It returns an error in the log in console. Uncaught SyntaxError: Invalid or :8000/UnityLibrary/B…y.framework.js.br:1 unexpected token
this is my steps
1.
build flutter web
flutter build web --web-renderer canvaskit -t lib/main.dart
Launch a web server by python
python -m http.server 8000
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.
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.
After installing flutter and running my emulator it stops at initializing gradle on android studio and on vs code.
It outputs:
this is taking an unexpectedly long time.
I ran flutter doctor and no issues and also flutter doctor -v and still no issues. I tried flutter upgrade but still no difference.
What is the next thing to try?
flutter error log
It looks like it is just taking forever to start; You can read the thread on the issue on
Github:
To summaries: here is one of the issues: Downloading 400mb of dependencies
Solved Initializing gradle problem
The problem is that when first time we are trying to run our flutter
project it does not have the required flutter gradle file. The
required file size that gradle downloads is about 300-400MB that's why
it takes so much time. Following are the steps:
Run your project by clicking on the 'Run' button or flutter run in the command terminal
Then go to the place where your .gradle file is located (usually it is in the C:\Users). In the .gradle folder there is file
name as wrapper in this there is dists folder. In dists folder there
is gradle folder which is being downloaded.
wait till the gradle file is being downloaded and after sometime your project would compile.
its working thaaaaaanks
I am new to mobile development; Everything takes eternity.
Solved this issue by removing all the gradle files from
C:\Users\.gradle\wrapper\dists
Now when you run your flutter app, it will automatically download the required gradle files.
Enjoy!!!
I have added the flutter webview plugin but its causing problems. Its giving some error when building the project. I tried to delete the cache and rebuild the project but it didn't work.
I just started learning flutter and can't find a solution to this problem.
Below is the error I am getting.
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':flutter_webview_plugin:compileDebugJavaWithJavac'.
Unable to find source java class: 'C:\Users\personal\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\flutter_webview_plugin-0.0.9+1\android\src\main\java\com\flutter_webview_plugin\WebviewActivity.java' because it does not belong to any of the source dirs: '[C:\Users\personal\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\flutter_webview_plugin-0.1.5\android\src\main\java, C:\Users\personal\AppData\Roaming\Pub\Cache\hosted\pub.dartlang.org\flutter_webview_plugin-0.1.5\android\src\debug\java, C:\Users\personal\Documents\AndroidStudioProjects\flutter_newz\build\flutter_webview_plugin\generated\source\r\debug, C:\Users\personal\Documents\AndroidStudioProjects\flutter_newz\build\flutter_webview_plugin\generated\source\buildConfig\debug, C:\Users\personal\Documents\AndroidStudioProjects\flutter_newz\build\flutter_webview_plugin\generated\source\aidl\debug, C:\Users\personal\Documents\AndroidStudioProjects\flutter_newz\build\flutter_webview_plugin\generated\source\rs\debug]'
BUILD FAILED in 54s
Finished with error: Gradle build failed: 1
I was using other plugins for firebase auth, firebase analytics, google sign in , webview, ect. Updating all the plugins to the latest version solved the problem.