I am working on a Xamarin application (Android application). When i run my application on emulator, i get the following error
C:\Program Files (x86)\Android\android-sdk\emulator\emulator.EXE -no-boot-anim -avd my_device -prop monodroid.avdname=my_device
Emulator my_device cannot be started.PANIC: Cannot find AVD system path. Please define ANDROID_SDK_ROOT1>------ Build started: Project: ReadoutSoftware.XAndroid, Configuration: Debug Any CPU ------
I did set the environment variables like this:
ANDROID_HOME : C:\Users\wnaveed\AppData\Local\Android\Sdk
ANDROID_SDK_ROOT : C:\Program Files (x86)\Android\android-sdk
I have also tried this:
ANDROID_SDK_ROOT : C:\Program Files (x86)\Android\android-sdk
but i still get the same error.
I am new to Xamarin, so any help would be much appreciated
Related
My environment is
Windows 10 Home Single Language 21H1
VS2019 Community 16.11.7
Android Emulator 30.1.5
HAXM 7.5.6
I can run Android 9.0 (API 28) in Android Emulator.
But I can't run Android 10.0 (API 29) and Android 11.0 (API 30) in Android Emulator. The emulator will start then stop by itself, no error message.
Following is my Android 11.0 (API 30), others are set as default.
Base Device: Pixel 2 (+ Store)
Processor: x86
OS: R 11.0 - API 30
I need to test in Android 11.0. What cause the error and how to fix it?
Update 2021-12-01
I've try following steps.
Change from fastboot.forceFastBoot to fastboot.forceColdBoot. Not working.
Reduce hw.cpu.ncore from 4 to 1. Not working.
Reduce hw.ramSize from 1536 to *768. Not working.
I've try start the emulator from command, and here is what I got:
"C:\Program Files (x86)\Android\android-sdk\emulator\emulator.EXE" -partition-size 512 -no-boot-anim -feature WindowsHypervisorPlatform -avd pixel_2_r_11_0_-_api_30 -prop monodroid.avdname=pixel_2_r_11_0_-_api_30
emulator: WARNING: Crash service did not start
Active code page: 65001
WARNING: unexpected '-prop' value ('monodroid.avdname=pixel_2_r_11_0_-_api_30'), only 'qemu.*' properties are supported
Failed to open /qemu.conf, err: 2
HAX is working and emulator runs in fast virt mode.
Active code page: 65001
C:\Program Files (x86)\Android\android-sdk\emulator\qemu\windows-x86_64\qemu-system-x86_64.exe: error while loading state for instance 0x0 of device 'goldfish_pipe'
deleteSnapshot: for default_boot
VCPU shutdown request
emulator: Saving state on exit with session uptime 255 ms
Thanks
Yesterday I decided to try out VS2019 for Xamarin projects, so I created a Xamarin.Forms project and selected Master-Detail template.
Once it was created, I simply debug it (F5) and I see the test app in the Android emulator. Everything works fine.
Today, I try to run the app again, I have changed absolutely nothing in the code. I rebuild the solution and it builds successfully.
When I run the app, it fails for this reason:
1>Starting deployment to Android_Accelerated_x86_Oreo ...
1>Starting emulator Android_Accelerated_x86_Oreo ...
1>C:\Program Files (x86)\Android\android-sdk\emulator\emulator.EXE -no-boot-anim -avd Android_Accelerated_x86_Oreo -prop monodroid.avdname=Android_Accelerated_x86_Oreo
1>emulator: ERROR: This AVD's configuration is missing a kernel file! Please ensure the file "kernel-qemu" is in the same location as your system image.
1>emulator: ERROR: ANDROID_SDK_ROOT is undefined
1>Emulator Android_Accelerated_x86_Oreo cannot be started.
========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========
The only solutions I have found deal with Android Studio, but I'm using Visual Studio 2019.
What can the issue be?
I am using Visual studio on windows to debug on my android device. I already cranked up the heap to 1G and added android:largeHeap="true" to the manifest in the application node.
Sometime I am able to start the debugger.. IN other times it will stop to the java.lang.OOM error. If I press Debug again.. it works.
How can I make it works everytime ?
here is the error:
Severity Code Description Project File Line Suppression State
Error XA5213: java.lang.OutOfMemoryError. Consider increasing the value of $(JavaMaximumHeapSize). Java ran out of memory while executing 'java.exe -Xmx1G -jar "C:\Program Files (x86)\Android\android-sdk\build-tools\26.0.2\lib\dx.jar" --dex --no-strict --output obj\Debug\MonoAndroid90\android\bin C:\Users\cpu\Desktop\programmation\my-project\project\obj\Debug\MonoAndroid90\android\bin\classes.zip "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v9.0\mono.android.jar" obj\Debug\MonoAndroid90\lp\10\jl\bin\classes.jar obj\Debug\MonoAndroid90\lp\12\jl\bin\classes.jar obj\Debug\MonoAndroid90\lp\13\jl\bin\classes.jar obj\Debug\MonoAndroid90\lp\14\jl\bin\classes.jar obj\Debug\MonoAndroid90\lp\15\jl\bin\classes.jar obj\Debug\MonoAndroid90\lp\16\jl\bin\classes.jar obj\Debug\MonoAndroid90\lp\17\jl\bin\classes.jar obj\Debug\MonoAndroid90\lp\18\jl\bin\classes.jar obj\Debug\MonoAndroid90\lp\19\jl\bin\classes.jar obj\Debug\MonoAndroid90\lp\20\jl\bin\classes.jar obj\Debug\MonoAndroid90\lp\21\jl\bin\classes.jar obj\Debug\MonoAndroid90\lp\22\jl\bin\classes.jar obj\Debug\MonoAndroid90\lp\23\jl\bin\classes.jar obj\Debug\MonoAndroid90\lp\24\jl\classes.jar obj\Debug\MonoAndroid90\lp\25\jl\classes.jar obj\Debug\MonoAndroid90\lp\26\jl\classes.jar obj\Debug\MonoAndroid90\lp\27\jl\classes.jar obj\Debug\MonoAndroid90\lp\28\jl\classes.jar obj\Debug\MonoAndroid90\lp\29\jl\classes.jar obj\Debug\MonoAndroid90\lp\3\jl\okhttp-2.4.0.jar obj\Debug\MonoAndroid90\lp\30\jl\classes.jar obj\Debug\MonoAndroid90\lp\31\jl\classes.jar obj\Debug\MonoAndroid90\lp\4\jl\okio-1.5.0.jar obj\Debug\MonoAndroid90\lp\5\jl\picasso-2.5.2.jar obj\Debug\MonoAndroid90\lp\7\jl\arch-core-common.jar obj\Debug\MonoAndroid90\lp\8\jl\arch-lifecycle-common.jar obj\Debug\MonoAndroid90\lp\9\jl\bin\classes.jar' 0
It may be Picasso.. but I use it like this in my code so it shouldn't cause a problem with the memory I think:
Picasso.With(activity)
.Load(url)
.Fit()
.MemoryPolicy(MemoryPolicy.NoCache)
.MemoryPolicy(MemoryPolicy.NoStore)
.Into(image);
I have an Xamarin Android project. Now I cannot get the app started in the emulator anymore. After building the solution the emulator starts but the app is never deployed.
The output window in Visual Studio shows this:
Starting deploy EmulatorName ...
Starting emulator EmulatorName ...
C:\Users\USERNAME\AppData\Local\Android\Sdk\tools\emulator.EXE -partition-size 512 -no-boot-anim -avd EmulatorName -prop monodroid.avdname=EmulatorName
emulator: WARNING: Crash service did not start
emulator: WARNING: encryption is off
Hax is enabled
Hax ram_size 0x40000000
HAX is working and emulator runs in fast virt mode.
Emulator EmulatorName is running.
Waiting for emulator to be ready...
Deploying EmulatorName ...
Build started.
...
Using "AndroidZipAlign" task from assembly "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MS
PackagedResources:
obj\Debug\android\bin\packaged_resources
SDCardDirectory:
External: False
ManifestTemplate: obj\Debug\android\AndroidManifest.xml
EnableInstantRun: False
InstantRunForceUploadApk: True
AndroidSdkPath: C:\Users\username\AppData\Local\Android\Sdk
AndroidNdkPath: C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b
JavaSdkPath: C:\Program Files (x86)\Java\jdk1.8.0_112
Found AndroidSdk at C:\Users\username\AppData\Local\Android\Sdk
Found AndroidNdk at C:\ProgramData\Microsoft\AndroidNDK64\android-ndk-r13b
Found AndroidTools at C:\Users\username\AppData\Local\Android\Sdk\tools
DEBUG RunShellCommand emulator-5554 getprop
TASK: GetProperties getprop completed?:[dalvik.vm.dex2oat-Xms]: [64m]
[dalvik.vm.dex2oat-Xmx]: [512m]
[dalvik.vm.heapsize]: [256m]
[dalv...
Getting this error when trying to run one of the Xamarin.Forms navigation samples from GitHub (MasterDetailsPage)
Severity Code Description Project File Line Suppression State Error
java.lang.OutOfMemoryError. Consider increasing the value of
$(JavaMaximumHeapSize). Java ran out of memory while executing
'java.exe -jar "C:\Program Files
(x86)\Android\android-sdk\build-tools\23.0.3\lib\dx.jar" --dex
--no-strict --output obj\Debug\android\bin \MasterDetailPage\Droid\obj\Debug\android\bin\classes\classes.zip
"C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v8.0\mono.android.jar"
obj\Debug\lp\0\jl\formsviewgroup.jar
obj\Debug\lp\10\jl\bin\classes.jar obj\Debug\lp\11\jl\bin\classes.jar
obj\Debug\lp\12\jl\bin\classes.jar obj\Debug\lp\13\jl\bin\classes.jar
obj\Debug\lp\14\jl\bin\classes.jar obj\Debug\lp\15\jl\bin\classes.jar
obj\Debug\lp\16\jl\bin\classes.jar obj\Debug\lp\17\jl\bin\classes.jar
obj\Debug\lp\18\jl\bin\classes.jar obj\Debug\lp\19\jl\bin\classes.jar
obj\Debug\lp\20\jl\bin\classes.jar obj\Debug\lp\21\jl\bin\classes.jar
obj\Debug\lp\3\jl\arch-core-common.jar
obj\Debug\lp\4\jl\arch-lifecycle-common.jar
obj\Debug\lp\5\jl\bin\classes.jar obj\Debug\lp\6\jl\bin\classes.jar
obj\Debug\lp\8\jl\bin\classes.jar obj\Debug\lp\9\jl\bin\classes.jar
C:\Users\me\AppData\Local\Xamarin\Xamarin.GooglePlayServices.Basement\8.4.0\embedded\classes.jar'
MasterDetailPageNavigation.Droid
I tried setting android:largeHeap to true in the AndroidManifest.xml
But the error didn't go away
I also tried to set the Java Max Heap Size to 1G in the Android Advanced Options under the project properties - the project builds without errors but that's about it, the emulator doesn't launch (or if I have it open nothing happens within it - the app doesn't start)
I read somewhere , that if the emulator doesn't start it means there isn't enough memory for it so it fails silently. I forget exactly the details.
But I have plenty of free RAM on my machine 12GB in total and between 6 - 8 GB avail, when visual studio is running.
The problem occurs while building the app not when running. Open the properties of the Android project and there Android options->Advanced you will find Java Max Heap Size. Using a value of 1G (for one gigabyte) should fix the memory problem.