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

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

Related

Failed to open APK, Invalid file when running my dart code using visual studio

I'm unable to run my android emulator. I have already checked flutter doctor in cmd and no issues has been found.
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.10.4, on Microsoft Windows [Version 10.0.22000.556], locale en-MY)
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.3)
[√] Android Studio (version 2021.1)
[√] VS Code (version 1.66.1)
[√] Connected device (4 available)
[√] HTTP Host Availability
• No issues found!
However, it shows built failed with an exception as below
Launching lib\main.dart on Android SDK built for x86 in debug mode...
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
> Android resource linking failed
AAPT: error: failed to open APK: Invalid file.

avoid use of removable GPUs (via com.apple.CoreSimulator.simctl:GPUSelectionPolicy->avoidRemovable)

Today when I start the flutter app in Mac Book Pro M1(the code did not change and runs fine in the Old 2019 Mac Book Pro), shows error like this:
This will generate a JSON format file containing all messages that
need to be translated.
Launching lib/main.dart on iPhone 13 in debug mode...
Running pod install...
Running Xcode build...
Xcode build done. 35.1s
Exception: Unable to launch com.earth.dolphin on 1DF4FFBC-4606-4406-A67D-8A263A470676:
ProcessException: Process exited abnormally:
com.earth.dolphin: -1
2022-03-06 18:23:50.661 simctl[62639:2998773] apply_selection_policy_once: avoid use of removable GPUs (via com.apple.CoreSimulator.simctl:GPUSelectionPolicy->avoidRemovable)
An error was encountered processing the command (domain=FBSOpenApplicationServiceErrorDomain, code=3):
The request to open "com.earth.dolphin" failed.
The process did launch, but has since exited or crashed.
Command: /usr/bin/arch -arm64e xcrun simctl launch 1DF4FFBC-4606-4406-A67D-8A263A470676 com.earth.dolphin --enable-dart-profiling --enable-checked-mode --verify-entry-points --start-paused --observatory-port=0
Error launching application on iPhone 13.
why did this happen and what should I do to fix it? Seems no one facing the problem after searching from Google. This is the flutter info:
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.10.2, on macOS 12.2.1 21D62 darwin-arm, locale en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2021.1)
[✓] Android Studio (version 2021.1)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2)
[✓] IntelliJ IDEA Ultimate Edition (version 2021.3.1)
[✓] VS Code (version 1.64.2)
[✓] Connected device (3 available)

Flutter error while adding web support to app

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.

Error connecting to the service protocol: Exception: Attempted to connect to Dart observatory 5 times, and all attempts failed. Giving up. The URL was

My app starts but then stops because of the error. I am using Windows 10, android studio as an IDE, and trying to build an android app.
if I use a terminal outside of Android studio it works, so it should be android studio related.
console:
Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Gradle task 'assembleDebug'...
Built build\app\outputs\apk\debug\app-debug.apk.
Installing build\app\outputs\apk\app.apk...
Error connecting to the service protocol: Exception: Attempted to connect to
Dart observatory 5 times, and all attempts failed. Giving up. The URL was
ws://127.0.0.1:50997/ws
flutter Doctor:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version
10.0.16299.847], locale de-DE)
[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
X Android license status unknown.
[√] Android Studio (version 3.2)
[√] Connected device (1 available)
! Doctor found issues in 1 category.
If you have configured a proxy,
ensure you have also set the environment variable
NO_PROXY=127.0.0.1

Flutter Hello world app can't start on Android Emulator x86_64

I am currently working on Xamarin Forms and want to try Flutter.
I created a Flutter project with Android Studio. But I can't run it.
I get this error on Android Emulator
Error launching the application on Android SDK built for x86 64.
flutter doctor looks fine.
some example app like Flutter Gallery can work but some can't.
The platform is Windows 10 64 bit.
Android Studio 3.2.1
Error Message is:
Launching lib\main.dart on Android SDK built for x86 64 in debug
mode... Initializing gradle... Resolving dependencies...
Gradle task 'assembleDebug'... Built
build\app\outputs\apk\debug\app-debug.apk. Installing
build\app\outputs\apk\app.apk... Error: ADB exited with exit code
1 adb: failed to install
C:\Users\xxx\source\flutter\flutter_app\build\app\outputs\apk\app.apk:
Error launching application on Android SDK built for x86 64.
C:\flutter>flutter doctor Doctor summary (to see all details, run
flutter doctor -v): [√] Flutter (Channel stable, v1.0.0, on
Microsoft Windows [Version 10.0.17134.472], locale zh-TW) [√]
Android toolchain - develop for Android devices (Android SDK
28.0.3) [√] Android Studio (version 3.2) [√] IntelliJ IDEA Community Edition (version 2018.3) [!] VS Code, 64-bit edition
(version 1.30.1) [!] Connected device
! No devices available
! Doctor found issues in 2 categories.
As you can see from those lines:
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
You are missing the plugin for flutter and dart.
Go to:
File -> Settings -> Plugins
and install Flutter
And check to see if dart was installed as well