Flutter error while adding web support to app - flutter

I just found out that I can change my flutter app to a website without writing external code. I decided to test it on my app but I got this error and I have no idea how to fix it. I followed the steps on the "website" but still I get the error. My stacktrace is :-
This application is not configured to build on the web.
To add web support to a project, run `flutter create .`.
Launching lib\main.dart on Web Server in debug mode...
Syncing files to device Web Server...
org-dartlang-app:/web_entrypoint.dart:8:8: Error: Error when reading 'lib/generated_plugin_registrant.dart': The system cannot find the file specified.
import 'package:discountapp/generated_plugin_registrant.dart';
^
org-dartlang-app:/web_entrypoint.dart:11:3: Error: Method not found: 'registerPlugins'.
registerPlugins(webPluginRegistry);
^^^^^^^^^^^^^^^
Failed to compile application.
I run flutter create . and it says
C:\Users\Hemant\AndroidStudioProjects\discountapp\ios>flutter create .
Recreating project ....
Wrote 3 files.
All done!
[√] Flutter: is fully installed. (Channel beta, 1.20.0-7.2.pre, on Microsoft Windows [Version 10.0.18363.959], locale en-US)
[√] Android toolchain - develop for Android devices: is fully installed. (Android SDK version 29.0.3)
[√] Chrome - develop for the web: is fully installed.
[√] Android Studio: is fully installed. (version 4.0)
[√] Connected device: is fully installed. (3 available)
In order to run your application, type:
$ cd .
$ flutter run
Your application code is in .\lib\main.dart.
C:\Users\Hemant\AndroidStudioProjects\discountapp\ios>flutter create .
Recreating project ....
Wrote 3 files.
All done!
[√] Flutter: is fully installed. (Channel beta, 1.20.0-7.2.pre, on Microsoft Windows [Version 10.0.18363.959], locale en-US)
[√] Android toolchain - develop for Android devices: is fully installed. (Android SDK version 29.0.3)
[√] Chrome - develop for the web: is fully installed.
[√] Android Studio: is fully installed. (version 4.0)
[√] Connected device: is fully installed. (3 available)
In order to run your application, type:
$ cd .
$ flutter run
Your application code is in .\lib\main.dart.
Running flutter run will run it on my phone. I will provide any code needed. Please help

You have to run flutter create . in application's root folder, but not in ios subfolder.

Rename ios folder to _ios
Run this command in your Terminal: flutter create --platforms=web .
Rename back _ios folder to ios
This will write all needed files to run your app on the browser.

Related

my new flutter app created is not working on my android device version 8

I just created a new flutter project with no dependencies added and I'm getting this errors
`* What went wrong:
A problem occurred evaluating project ':app'.
Could not initialize class com.android.build.gradle.internal.crash.PluginCrashReporter`
`
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 3.3.8, on Microsoft Windows [Version 10.0.19043.2251], locale en-US)
Checking Android licenses is taking an unexpectedly long time...[!] Android toolchain - develop for Android devices (Android SDK versio
n 32.0.0)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[√] Chrome - develop for the web
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2021.1)
[√] VS Code (version 1.73.1)
[√] Connected device (4 available)
[√] HTTP Host Availability
`
...and as you can see from my flutter doctor, everything looks fine and okay. Can someone please help me on this because I actually can't figure it out. Thank You.
I have tried upgrading the gradle but I'm still not getting a good result
Try to deleted .gradle caches by typing this in terminal rm -rf $HOME/.gradle/caches/ if error still exist proceed to step 2
Try the command with --scan,it could be ~/.android was owned by root, so your build (launch by my user) failed to read/write into this directory.
Solution: sudo chown -R you:you ~/.android
Accept Your Android licenses usinge this command
flutter doctor --android-licenses
After that accept all

Installation Process of Flutter

C:\Users\aakas>flutter doctor
'Information' is not recognized as an internal or external command,
operable program or batch file.
'Information' is not recognized as an internal or external command,
operable program or batch file.
Error: Unable to find git in your PATH.
[1]How to fix it, I already set the environment variable and dart is working but flutter is not working
Have you updated your Flutter path in your Environment variables?
update your path in environment variables and restart your system and run again flutter doctor in Command Terminal.
To run Flutter on your device properly you have to install these following things first:
Android Studio
Chrome (Browser)
Git
IntelliJ (Not sure if it's a must or not but flutter doctor does check for it)
Otherwise, you'll face difficulties for not installing any of them.
The following is the result I got after running flutter doctor on my device and it shows the things it checks for Flutter to be properly running.
[√] Flutter (Channel stable, 2.6.0-11.0.pre, on Microsoft Windows [Version 10.0.19043.1288], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[√] Android Studio (version 2020.3)
[√] IntelliJ IDEA Community Edition (version 2021.2)
[√] VS Code (version 1.62.1)
[√] Connected device (2 available)

Flutter2 - Can't find service: package (Android Studio -Windows10)

On upgrading a working project to Flutter_2 and running it , gives the error below.
As per answer to similar question ,Avd Data(Pixel_3a) has been wiped.
How to resolve this ?
ERROR
Can't find service: package / Can't find service: activity
FULL ERROR
Launching lib\forms\validateForm1.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...
√ Built build\app\outputs\flutter-apk\app-debug.apk.
cmd: Can't find service: activity
Installing build\app\outputs\flutter-apk\app.apk...
Error: ADB exited with exit code 1
Performing Streamed Install
adb: failed to install F:\Script\Flutter\myapp\build\app\outputs\flutter-apk\app.apk: cmd: Can't find service: package
Error launching application on sdk gphone x86 arm.
Flutter Doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel dev, 2.1.0-10.0.pre, on Microsoft Windows [Version 10.0.18363.1379], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[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 2019 16.8.3)
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.54.1)
[√] Connected device (2 available)
Deleting Avd related lock files resolved the issue.
Open Avd Manager -> ShowonDisk -> Delete following 2 lock files from disk --->
hardware-qemu & multiinstance.lock

flutter run -bash: Desktop/flutter/bin/flutter: No such file or directory

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.17.1, on Mac OS X 10.14.6 18G103, locale pl-PL)
[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from:
https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK
components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup
for detailed instructions).
If the Android SDK has been installed to a custom location, set
ANDROID_SDK_ROOT to that location.
You may also want to add it to your PATH environment variable.
[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
[!] Android Studio (not installed)
[!] Connected device
! No devices available
I created a my_app folder and typed:
cd my_app
flutter run
The "flutter run" command does not work. How to fix this?
Have you installed android sdk?
If not then installing Android Studio will will install all the required dependencies.
I faced this problem it easy to solve
Open Android Studio
And go to preference
Plugins
Download flutter & dart
You need Android SDK, if you plan on using Android Studio then SDK will be downloaded with the Android Studio
https://developer.android.com/studio is the link to download

Problem with Flutter Web. Chrome Beta is uninstalled but still showing up

I am facing a problem with the flutter web initialization. I followed the steps in https://flutter.dev/docs/get-started/web Everything went smooth
flutter channel beta
flutter upgrade
flutter config --enable-web
When I do Flutter Doctor I get
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v1.17.0, on Microsoft Windows [Version 10.0.18363.778], locale en-IN)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
X Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit visit https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.
[X] Chrome - develop for the web (Cannot find chrome executable at C:\Program Files (x86)\Google\Chrome Beta\Application)
! C:\Program Files (x86)\Google\Chrome Beta\Application is not executable.
[√] Android Studio (version 3.6)
[√] VS Code (version 1.44.2)
[√] Connected device (1 available)
! Doctor found issues in 2 categories.
I don't have chrome beta on my PC anymore. I have normal chrome. How to change it. Somebody help me out.
Also, I got found this online as a solution but I don't know what it means.
export CHROME_EXECUTABLE=path/to/chrome
This is not the solution but an alternative method you can try. If you are in the beta channel of flutter you can just type flutter build web that will create a web build in your web folder. You can run it on any other server just like normal web application. If you want to do this to an existing project first run flutter create . then flutter build web.