Flutter web throws error on same project but different laptop - flutter

So I just won a new laptop in a competition and now I am having some trouble migrating my flutter projects. I have set up the editor and migrated the important files in the code, i.e the lib, image, font, pubspec.yaml and web. But this app is now throwing the following error
Launching lib\main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
ERROR - 2020-12-29 13:08:07.845202
GET /main_module.bootstrap.js
Error thrown by handler.
AbsoluteImportUriError: 'file:///C:/FlutterProjects/xspectre/lib/help/Auth.dart'
package:dwds/src/debugging/metadata/provider.dart 154:9 MetadataProvider._addMetadata
package:dwds/src/debugging/metadata/provider.dart 133:15 MetadataProvider._initialize.<fn>
I thought it may be a problem with my flutter but it runs the default flutter app without problem.
I also tried deleting the file but the problem just shifts to another file. I can safely say that this a is a problem with the help folder which provides me essential tools such as the auth service. What should I do? I will provide any code neccesary. You can find the entire code here

The Error:
The error is happening because when importing your new project, some imports in your .dart files are now using absolute paths instead of relative paths. In your case, this is happening at least in one .dart file that is calling your Auth.dart.
Sloution:
Step 1: Look at the top of all your .dart files, more precisely at every single import. You will have to change everything starting with:
import 'file:///C:/...
by
import 'package:... and add the name of your app
Step 2: Rerun your project and everything should work now
If still issues, then make sure you looked at all your files to ensure you did not miss other wrong import... also, you can run flutter clean then run a Pub Get
(thanks to melwinlobo18)
Please mark the answer if this was useful ;0)

Related

flutter build web doesn't create flutter.js

I recently made a flutter application and now I want to get a web release, but when I run flutter build web and upload stored files in {root}/build/web on the host, everything is showing on chrome and firefox with that URL is an empty page with 2 console errors:
_flutter is not defined
GET https://web.pushers.ir/flutter.js 404
I took a look at my released files and didn't see any file named flutter.js, I tried flutter build web many times but nothing, also I tried to create another flutter project as a sample and ran flutter web build, on that sample everything was ok and flutter.js created with other released files
What should I do?
notice: it's working with Microsoft Edge, even while there is no file named flutter.js
Had the same issue.
Long story short: run flutter clean instead of manually deleting the /build/web folder or its content. The next build that follows will properly generate all files, including flutter.js.
More info why that is happening
I just copied flutter.js from a sample project release into my app release and it works

Flutter exception while building

I tried to run/debug my application on the desktop (after installing visual studio 2019 with all defaults) but I can't :) and this error occurred:
D:\Visual Studio IDE\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(240,5): error MSB8066: Custom build for 'D:\Location\Some Location\MyFlutterAppLocation\build\windows\CMakeFiles\a50fa560346c71769b697565b5a2d59b\flutter_windows.dll.rule;D:\Location\MyFlutterAppLocation\build\windows\CMakeFiles\eb8cecdef0b53de6eb232004d53dfd8a\flutter_assemble.rule' exited with code 1. [D:\Location\Some Location\MyFlutterAppLocation\build\windows\flutter\flutter_assemble.vcxproj]
Exception: Build process failed.
Few times when I faced a .vcxproj error, I had a previously built .exe process running, even after closing it. I ended the .exe via task manager and the issue was solved. You can spot the running build using the flutter icon or the supplied app icon.
In another instance, I faced a similar error after I interrupted previous flutter run. In this case, I wasn't able to spot the .exe as it wasn't completely built. I don't know which process is specifically using .vcxproj. Hence I resorted to a cleaning of the project:
flutter clean
flutter create --platforms=windows,web,android .
flutter run
Though this second case doesn't pinpoint the source of the error, I was happy to have solved it without restarting VSCode or signing out of windows.

Flutter error: Unable to locate gradlew script

I can't run all of my flutter apps, because in the console appears everytime this error message:
Downloading Gradle Wrapper... 1,2s
Launching lib\main.dart on SM G960F in debug mode...
Running Gradle task 'assembleDebug'...
Finished with error: Unable to locate gradlew script. Please check that C:\Users\...\android\gradlew.bat exists or that C:\Users\...\android can be read.
I try to fix this problem more than ten hours and don't find a solution.
I will advise you to check your pc properly for unwanted programs. Something is preventing your pc from running the Gradle. I had the same issue only to realize that antivirus was installed on my pc alongside a cd burner that I just installed. Check for any antivirus that might be preventing Gradle from running.
I also faced the same error initially. While creating a flutter application from scratch I just ran the default flutter application which is a counter app in a flutter. I faced the same issue at first. If you are in this same context as described earlier the following could be the solution
1.Java 8 is more suitable for the flutter/android development. The next versions of java have some exceptions. I used the Java 14 and stuck at this issue for some time
The next could be the JAVA_HOME path in your environment variables. If it is not provided the set the JAVA_HOME path.
Run flutter --doctor and check the requirements if satisfied like Android SDK is updated or not, upgrade flutter if required. In some cases having good Internet connection also plays a role in this issue some times.
These are the major points to be satisfied in order to get rid of this error. Mostly this could be the a solution or part of it.
The error suggests that something is preventing gradle to run properly on your machine. Check whether you have any unwanted programs or anti-virus on your machine running that might be preventing gradle to run. If so, remove or stop those programs / anti-virus and try again.
After that, delete the .gradle folder located here C:\Users\yourPcName\.gradle containing the unfinished file and try again . It will work now .
You can also manually download Gradle and map it in Android studio , Learn more with this article here .
Warning, the gradle versions change quickly, so make sure you manually
downloaded the exact version that flutter wanted to download and the
download failed. Download the gradle here and then replace it in the
gradle folder.
C:\Users\yourPcName\.gradle\wrapper\dists\gradle-x.x.x-all
If it still doesn't work,
Try to run flutter --doctor
From a console window that has the Flutter directory in the path (see above), run the following command to see if there are any platform dependencies you need to complete the setup:
C:\src\flutter> : flutter doctor
This command checks your environment and displays a report of the status of your Flutter installation. Check the output carefully for other software you might need to install or further tasks to perform (shown in bold text).
You can learn more here :
If flutter doctor itself doesn't work, then know that flutter is not installed on your machine (or you forgot to add it to the environment
variable).
I also faced this problem and I made something to run my app on android
tried to open anything on android files and android studio ask me if I want to open for editing android file in android studio then click on it and it will open android project then click run enter image description here

How do I edit running configuration in Flutter/Android Studio?

I created an app in Flutter and it was running fine, but I adjusted something and when I tried to debug it on the emulator, a new window popped up which I think was called "Configuration Editor" or something. I'd no idea what to do with it, but the app wouldn't run without it, so I entered some random data in one of the fields to see what would happen.
Now Android Studio seems to be trying to run the app with this data, and it won't run. I'm getting the error:
Target file "4,6,8" not found.
where "4,6,8" is the data I entered. I assume I need to blank out those fields again, but I don't know how to open the configuration file or whatever it was where I entered the data!
I assume you messed up the running configuration for the project, setting a file that doesn't exist "4,6,8".
Anyway, if this is the problem, you can configure it again in Android Studio:
Then set the entry file 'main.dart' of your project. The 'additional arguments' and 'flavor' are optional.
In my case it occur due to the reason that pubspec.yaml is missing that is why main.dart is not running as it did not found flutter sdk and other dependencies present pubspec.yaml file.

Getting Flutter doctor to work

How do I get flutter doctor on my Windows 10 laptop to work, please?
I followed the guidelines here,
Used git to clone the flutter repository,
git clone -b alpha https://github.com/flutter/flutter.git,
Tried adding "C:\Users\<user>\flutter\bin" to my path in the Control Panel
and then in an Admin Powershell, tried executing flutter doctor.
At first, it just hung.
After googling for help, I tried deleting the contents of the
C:\Users\<user>\flutter\bin\cache folder and re-executing flutter doctor but to no avail.
Then, I tried deleting all of flutter and cloning again but flutter doctor just hung again but with, Updating flutter tool.
Tried a few different Googled PATH-adding ideas (that seems to be a complex and disputed area.)
Got a new message: Waiting for another flutter command to release the startuplock
The latest state is that flutter doctor still just hangs but without any message.
I suspect the problem lies in the new Path not being properly recognised (in the registers??)
Can anyone help please?
Well, the issue is not clear enough, but this might be solution, if your flutter doctor is stuck, it might be due to Background Intelligent Transfer Service is disabled, in order to check for yourself, do the following:
Click on the start menu, and then start typing services.
Launch the services and look for Background Intelligent Transfer Service and make sure it is running.
At this stage I believe you will find it disabled for some reason, just right click on it and go to properties and start the service, also change the startup type to automatic.
I can not think of other reasons that might prevent flutter doctor to run for the first time on a Windows machine other than that honestly.
I know this question is a little bit old. Here is a solution that worked for me. Run the Command Prompt as an admin solved the issue for me.
For Windows user check to see if the unzipped flutter folder is read only. (i.e right click the folder then properties then in the attributes section untick the readonly property then apply this change to the folder along with the sub-folders then ok and thats it. Worked for me.
Some errors I got and how I fixed it:
(ERROR 1):
[flutter] flutter doctor -v 'crumb' is not recognized as an internal or external command, operable program or batch file.
Error: Unable to find git in your PATH. exit code 1
(Fix) - Go to flutter installation folder and inside flutter/bin edit the flutter.bat file using a text editor and remove the line (20) that says:
IF EXIST "%mingit_path%" SET PATH=%PATH%;%mingit_path%
The code should look like this on those lines:
REM If available, add location of bundled mingit to PATH
SET mingit_path=%FLUTTER_ROOT%\bin\mingit\cmd
Save and Run flutter doctor and everything should work fine.
(ERROR 2):
flutter doctor takes too long
(Fix) - I downloaded the previous version of the sdk it worked like a charm.
(ERROR 3):
Android sdkmanager not found. Update to the latest Android SDK and ensure that the cmdline-tools are installed to resolve this.
(Fix):
Open Android Studio
Tools Menu, SDK Manager
In the window that comes up there are inner panels, choose SDK Tools panel
Tick Android SDK Command-line Tools
Choose Apply button near the bottom of the window
This worked.
(ERROR 4):
The term 'flutter' is not recognized as the name of a cmdlet, function, script file, or operable program.
(Fix) - Put the correct part in the env variables. I had put D:\flutter instead of D:\flutter\bin. That worked.
I got a solution that worked for me
initially i had downloaded the 2.2.5 SDK which gave the forever run error so i went back and downloaded the previous version ie 2.2.2 it worked like a charm
The Flutter SDK is installed in a protected folder and may not function correctly. Please move the SDK to a location that is user-writable without Administration permissions and restart.