Visual Studio Community 2022 Android Emulator won't build - android-emulator

I’ve tried almost everything I can think of and none of it has even made a dent.
Whenever I try to execute my application, the device attempts to boot twice, quickly flashing on screen then disappearing, with a warning message inside the temporarily emulated device reading: “Resetting for cold boot: emulator engine failed” (I have tried this from both new devices and devices with force.ColdBoot disabled).
Whenever I try to execute my application, the device attempts to boot twice, quickly flashing on screen then disappearing, with a warning message inside the temporarily emulated device reading: “Resetting for cold boot: emulator engine failed” (I have tried this from both new devices and devices with force.ColdBoot disabled).
Nothing seems out of place in the Android Debug Properties menu.
I have HAXM enabled.
I’ve reinstalled Visual Studio. The emulated devices were still in Android Device Manager in the new version if that matter.
Every thread I’ve searched is either irrelevant, outdated, or merely tangential to my problem.
It changes a bit with each of the modifications I made, but the output from the build is always something like this:
Build started...
Starting emulator tablet_h-dpi_13_5in_-_api_33 ...
1>------ Build started: Project: MobileApplicationAssessment.Android, Configuration: Debug Any CPU ------
C:\Program Files (x86)\Android\android-sdk\emulator\emulator.EXE -netfast -accel on -avd tablet_h-dpi_13_5in_-_api_33 -prop monodroid.avdname=tablet_h-dpi_13_5in_-_api_33
1>C:\Users\Alistair\source\repos\MobileApplicationAssessment\MobileApplicationAssessment.Android\Properties\AndroidManifest.xml : warning XA4211: AndroidManifest.xml //uses-sdk/#android:targetSdkVersion '31' is less than $(TargetFrameworkVersion) ''. Using API-33 for ACW compilation.
1>C:\Users\Alistair\source\repos\MobileApplicationAssessment\MobileApplicationAssessment\MobileApplicationAssessment.csproj : warning NU1701: Package 'Microsoft.Bcl 1.1.6' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
1>C:\Users\Alistair\source\repos\MobileApplicationAssessment\MobileApplicationAssessment\MobileApplicationAssessment.csproj : warning NU1701: Package 'Microsoft.Bcl.Async 1.0.165' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
1>C:\Users\Alistair\source\repos\MobileApplicationAssessment\MobileApplicationAssessment\MobileApplicationAssessment.csproj : warning NU1701: Package 'PCLStorage 1.0.2' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.
1> MobileApplicationAssessment.Android -> C:\Users\Alistair\source\repos\MobileApplicationAssessment\MobileApplicationAssessment.Android\bin\Debug\MobileApplicationAssessment.Android.dll
2>Starting deployment to tablet_h-dpi_13_5in_-_api_33 ...
2>Starting emulator tablet_h-dpi_13_5in_-_api_33 ...
2>C:\Program Files (x86)\Android\android-sdk\emulator\emulator.EXE -netfast -accel on -avd tablet_h-dpi_13_5in_-_api_33 -prop monodroid.avdname=tablet_h-dpi_13_5in_-_api_33
2>Emulator tablet_h-dpi_13_5in_-_api_33 cannot be started.
========== Build: 1 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
========== Elapsed 00:31.315 ==========
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
========== Elapsed 00:31.315 ==========
Any help would be greatly appreciated, and it’s worth noting I’ve only been using VS for about a year, so I might not know all the terminology and whatnot, so if you could break down those in your answers that would, also, be appreciated.

Related

Flutter Gradle task assembleDebug failed with exit code 1 zip END header not found

Hello I am new to Flutter I have setup flutter with android studio 4.2.1, and every thing is fine. When I try to run it; it show me following error
I see too much questions but it is not helpfull for me
flutter doctor run no issue found
Hers is doctor result
Here is my enviroment variable
can any one guide me how can I run the flutter. I am lunching it in a chrome
exception in thread "main" java.util.zip.ZipException: zip END header not found at
java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1567) at
java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1462) at
java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1469) at
java.base/java.util.zip.ZipFile$Source.(ZipFile.java:1274) at
java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1237) at
java.base/java.util.zip.ZipFile$CleanableResource.(ZipFile.java:727)
at
java.base/java.util.zip.ZipFile$CleanableResource.get(ZipFile.java:844)
at java.base/java.util.zip.ZipFile.(ZipFile.java:247) at
java.base/java.util.zip.ZipFile.(ZipFile.java:177) at
java.base/java.util.zip.ZipFile.(ZipFile.java:191) at
org.gradle.wrapper.Install.unzip(Install.java:214) at
org.gradle.wrapper.Install.access$600(Install.java:27) at
org.gradle.wrapper.Install$1.call(Install.java:74) at
org.gradle.wrapper.Install$1.call(Install.java:48) at
org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:48) at
org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:128)
at
org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Exception: Gradle task assembleDebug failed with exit code 1
I recently Solved this problem.
This Problem came from gradle file is corrupted in my system.
I'm using Linux so this steps almost same in windows also. This answer is for any gradle version.
Open File Manager:
enable Show hidden folder from top menu bar.
You may find this location : .gradle>wrapper>dists.
In Linux: Home > .gradle > wrapper > dists.
In Windows: C:>Users>{PC Name}>.gradle>wrapper>dists
Method 1
Go inside gradle-6.5-all > dists > 2oz4ud9k3tuxjg84bbf55q0tn. '2oz4ud9k3tuxjg84bbf55q0tn' may be different in your PC.
Delete all files in that folder and download required file manually: https://downloads.gradle-dn.com/distributions/gradle-6.5-all.zip
after download paste freshly downloaded zip file in that folder.
Run your project flutter run -v
Method 2
Try this if you have fast & stable internet connection.
Delete that gradle-6.5-all folder.
Open project in VS code or Android Studio and open terminal.
Run this command flutter run -v
Method 3
Flutter Doctor will give right result.
Open Android Studio
Create new flutter project
Click on Tools > flutter >Flutter for editing in android studio
and wait, flutter doctor takes time to identify problem.
Use this link for download gradle file.
Replace 6.5 with your gradle version.
https://downloads.gradle-dn.com/distributions/gradle-6.5-all.zip
I hope this answer helpful for you.
Please use the below command
1.Mac User :
rm -rf ~/.gradle
2.Windows User :
remove the .gradle file
.gradle file location -> C:\Users\myUser
I solve this error by updating the gradle plugin/version. I have as part of my configuration:
Windows 10
Android Studio 4.2.1
Java 11: Android Studio 4.2.1 don't have support for JDK 16, so, I installed JDK 11, and configured the AS (how to change the jdk in AS) to use this older JDK
Gradle 7.0.1
By default, when you create a new Flutter project, the IDE created it with basic standard configurations, so you have to change this configs to fit your current config. For that, you need to update the gradle config in the flutter project, as follow:
in android/gradle/build.gradle file: update the gradle plugin to 4.2.0 in the dependencies section, like this:
dependencies {
classpath 'com.android.tools.build:gradle:4.2.0'
//more dependencies
}
in android/gradle/wrapper/gradle-wrapper.properties file: update the gradle version, in this case I have the 7.0.1, feel free to use another one, like this
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.1-all.zip
//more attributes
After you change the gradle config, run this commands in your project:
flutter clean : clean the project
flutter pub get : update your dependencies
flutter run : run the project. Now it must work, at least it work for me
I faced the same problem in VSCode when I wanted to run the Flutter app I got that error, so after lots of debugging and research, I found the solution. it's pretty easy, just follow these steps:
In windows 10:
1. Open flutter project in a Text-Editor like VSCode.
2. Open android -> gradle -> wrapper -> gradle-wrapper.properties
3. You will find "gradle-6.7.1.all.zip" inside gradle-wrapper folder
4. Go to this path: C:\Users\your-user
5. Then go to the wrapper->dists and find "gradle-6.7.1.all" folder
5. Delete this folder.
6. Then come to VSCode and open Terminal.
7. Please make sure that you have stable internet connection then type this command in terminal
8. flutter run
I hope this solution can help you!
I solve this error by deleting the .gradle folder.
This location is gradle folder
In Windows: C:> Users> {PC Name}>. Gradle
After deleting this folder, you only need to run the application again in Android Studio. At this point, Android Studio starts downloading the deleted folder automatically.
enter image description here
This error is caused by corrupted gradle files, this is either due to incomplete downloads due to network issues. To solve it easily download the gradle zipped file from https://downloads.gradle-dn.com/distributions/gradle-6.7-all.zip and paste on the .gradle directory as shown below if you are on linux
enter image description here
I try all method but it did not work for me so i decided to location the gradle-wrapper.properties in the andriod folder then i change the distribution gradle link to a more recent gradle link.
Welcome SO.
Java 16/latest version is not fully compatible with the Gradle 6 at this moment. Try to use java 11 or 8, it will resolve your issue.

Flutter - Could not find a command named "-"

I'm new to flutter, when I created a new project of flutter and run it, this appears :
Using hardware rendering with device AOSP on IA Emulator. If you notice graphics artifacts,
consider enabling software rendering with "--enable-software-rendering".
Launching lib\main.dart on AOSP on IA Emulator in debug mode...
Could not find a command named "-".
Usage: dart [<vm-flags>] <command|dart-file> [<arguments>]
Global options:
-h, --help Print this usage information.
-v, --verbose Show additional command output.
--version Print the Dart SDK version.
--enable-analytics Enable anonymous analytics.
--disable-analytics Disable anonymous analytics.
Available commands:
analyze Analyze the project's Dart code.
compile Compile Dart to various formats.
create Create a new project.
fix Apply automated fixes to Dart source code.
format Idiomatically format Dart source code.
migrate Perform a null safety migration on a project or package.
pub Work with packages.
run Run a Dart program.
test Run tests in this package.
Run "dart help <command>" for more information about a command.
See https://dart.dev/tools/dart-tool for detailed documentation.
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done 510ms
Exception: Gradle task assembleDebug failed with exit code 64
I'm stuck with this problem, how to solve this?
I have solved this problem. I run this project in my D: directory while my flutter and android SDK was installed in C: directory. So, when I tried to create flutter project in C:, it worked. But, I still can't configure why this problem happened.
#Papskipapap may I ask, if running your project on D: also inculded some path name which contained a "-" (dash) in it? As a rule of thumb: Keep pathnames easy, i.e. without blanks or special characters other than "_" (underscore), many tools just can not handle those...

Issue in setting up the Android emulator with React native

I am fairly new to React native and trying to set up Android environment with Visual studio. All the installation has been fairly successful, however, when I try to run the sample app on the android emulator executing the npx react-native run-android command it shows below error -
'C:\Users\Home' is not recognized as an internal or external command,
operable program or batch file.
error Failed to launch emulator. Reason: Could not start emulator within 30 seconds..
Starting a Gradle Daemon, 1 incompatible and 1 stopped Daemons could not be reused, use --status for details
java.lang.NoClassDefFoundError: Could not initialize class org.codehaus.groovy.vmplugin.v7.Java7
at org.codehaus.groovy.vmplugin.VMPluginFactory.<clinit>(VMPluginFactory.java:43)
at org.codehaus.groovy.reflection.GroovyClassValueFactory.<clinit>(GroovyClassValueFactory.java:35)
at org.codehaus.groovy.reflection.ClassInfo.<clinit>(ClassInfo.java:109)
However, when i execute adb devices on visual studio, it shows the list of emulator connected -
List of devices attached
emulator-5554 device
What could be the possible reason? Is this because my users name is Home PC? (Is this because there is a space in between) and it is not able to get the correct path?
This is because your java version is updated to the latest version and gradle is not supported with the installed version. what you can do is update the gradle as well
So go to gradle/wrapper folder inside the android folder
Edit gradle-wrapper.properties file and replace distributionUrl
with following value
https\://services.gradle.org/distributions/gradle-6.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
I too faced the same issue.The problem is with the JDK. From JDK 14 i downgraded to JDK 11(LTS) version. And it worked.
Hope it helps.
Install Java 8 version, which is available Java 8 download
Gradle is not keeping up with the Java Latest versions, so roll back
to previous versions

How to remove or identify unused packages from flutter to reduce size of the project?

I used some packages that I no longer need in my flutter project, namely the wilddog_auth and wilddog_sync, I can remove the imports from pubspec.yaml file, and my dart files (aka removing import 'package:wilddog_sync/wilddog_sync.dart' etc.) and remove imports in MainActivity.java as well as in Xcode project but I can't purge the unused files installed by flutter, cocoapod and gradle. Now is there a unified command in flutter where I can remove all unused packages at once?
I am pretty sure using flutter clean only removes build folder and using flutter packages get after removing packages from pubspec.yaml doesn't remove packages from cocoapod or gradle either.
For example, after flutter clean and flutter packages get I rebuilt the project:
Launching lib/main.dart on Android SDK built for x86 64 in debug mode...
Initializing gradle...
Resolving dependencies...
Running 'gradlew assembleDebug'...
Built build/app/outputs/apk/debug/app-debug.apk.
Installing build/app/outputs/apk/app.apk...
I/FlutterActivityDelegate(11331): onResume setting current activity to this
I/Choreographer(11331): Skipped 107 frames! The application may be doing too much work on its main thread.
D/EGL_emulation(11331): eglMakeCurrent: 0x79f21b4dbec0: ver 2 0 (tinfo 0x79f219b4f160)
I/OpenGLRenderer(11331): Davey! duration=1903ms; Flags=1, IntendedVsync=7544454683637, Vsync=7546238016899, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=7546253803603, AnimationStart=7546253996603, PerformTraversalsStart=7546254171603, DrawStart=7546279222603, SyncQueued=7546288526603, SyncStart=7546295569603, IssueDrawCommandsStart=7546296644603, SwapBuffers=7546334455603, FrameCompleted=7546365204603, DequeueBufferDuration=2892000, QueueBufferDuration=199000,
Syncing files to device Android SDK built for x86 64...
D/ (11331): HostConnection::get() New Host Connection established 0x79f219ab81e0, tid 11383
D/EGL_emulation(11331): eglMakeCurrent: 0x79f21b5e26e0: ver 2 0 (tinfo 0x79f219aa66c0)
W/IInputConnectionWrapper(11331): getCursorCapsMode on inactive InputConnection
Yet all the package files remained.
Of course I could go into ./ios/ to run pods install to remove pods:
pod install
Analyzing dependencies
Fetching podspec for `Flutter` from `.symlinks/flutter/ios`
Removing Wilddog
Removing WilddogCore
Removing WilddogSync
Downloading dependencies
Using Flutter (1.0.0)
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
[!] Automatically assigning platform `ios` with version `8.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.
There is an intuitive way for it.
Install this package
dev_dependencies:
dependency_validator: ^x.x.x
Then run flutter pub run dependency_validator
It will show all the details about the packages installed.
Example: =>
These packages are pinned in pubspec.yaml:
dependency_validator: null -- This is a direct pin.
permission_handler: null -- This is a direct pin.
swipe_to: null -- This is a direct pin.
These packages are used in lib/ but are not dependencies:
connectivity
meta
path
The following packages contain executables, they are assumed to be used:
flutter_native_splash
These packages may be unused, or you may be using assets from these packages:
cupertino_icons
firebase_analytics
http
loading
sign_in_with_apple
delete the hosted folder of .pub-cache in flutter SDK directory
cd path/to/flutter_sdk_directory
rm -rf .pub-cache/hosted
delete the .packages file in the project root directory
cd path/to/project_root_directory
rm -rf .packages
get packages for the project
cd path/to/project_root_directory
flutter pub get
open the project in Android Studio
done.
Sometimes there might be packages that is not used in the project but you have installed sometime during the development stage. To find out those, First go to each dart file and remove the unused imports, then go to pubspec.yaml and comment the packages one by one and save the project. And then refresh the application(NOT HOT RELOAD). if the package us used in the project then it will throw you an error. After repeating the steps on all the packages you will be able to remove all the unwanted packages from your pubspec.
Now, delete the pubspec.lock file, and run the pub get again. Your project will now be having only the required packages and this could be the minimum size achievable.
There's an obvious way which is easy to overlook or think is not feasible.
If using IntelliJ, simply do "Find in files" (SHIFT+CTRL+F on PC, SHIFT+CMD+F on Mac), select "Directory" and choose the lib-folder of your project.
Then go through your list of plugins and search for the name of each one in turn. The plugin isn't used if
there are no search results for its name
it's only used in "generated_plugin_registrant.dart"
the only hits are import statements that are grey (marked as unused by IntelliJ)
Took me less than a minute to eliminate 8 unused plugins using this method.
You can use this three steps to clear this issue
'flutter clean'
Remove the unwanted dependencies in pubspec.yaml
Delete the pubspec.lock
Reload the project and again perform 'pub get' and run the iOS/Android project
This behavior seems to be a bug. You can track it here https://github.com/flutter/flutter/issues/65718
The best way to do this is
flutter clean
If this doesn't work just create a new project copy your old code into the new project and here you can add only the dependencies you want before running pub get.
You can remove by typing in terminal dart pub remove <packagename>
Example : To remove flutter_svg:^0.22.0 ,
type dart pub remove flutter_svg
For more informations, check https://dart.dev/tools/pub/cmd/pub-remove

Android Studio 3.0.1 Emulator Not Loading

my emulator stopped working after the most recent update. I am currently using the HAX module to run the emulator.
I cannot seem to find the updater for the Intel module (forgive me, I recently started using Android Studio).
Below is the event log which appears when I try to load the emulator:
23/02/2018
21:28 Platform and Plugin Updates: The following components are ready to update: Android Emulator, Google APIs Intel x86 Atom System Image
21:28 Gradle sync started
21:30 Project setup started
21:38 Gradle sync finished in 9m 17s 764ms
21:38 Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar]
21:38 Gradle build finished in 15s 456ms
21:41 * daemon not running; starting now at tcp:5037
21:41 * daemon started successfully
21:41 Executing tasks: [:app:assembleDebug]
21:41 Emulator: Incompatible HAX module version 3,requires minimum version 4
21:41 Emulator: No accelerator found.
21:41 Emulator: failed to initialize HAX: Invalid argument
21:41 Emulator: Process finished with exit code 0
21:41 Gradle build finished in 5s 978ms
Some help would be greatly appreciated! Also, if you find any more problems which could cause further issues to my program, please do notify me.
I had the same problem. I went to the Intel site (https://software.intel.com/en-us/articles/intel-hardware-accelerated-execution-manager-intel-haxm) and downloaded the latest version of HAXM. I then installed it, and the problem went away!