Android Studio Avd emulator shows a black flickering - android-studio

I have an issue all of a sudden where I am getting a weird black flickering at the bottom of the screen (as shown in the video below). I had no problem earlier also this happened after I removed android emulator and rechecked it (Reinstalled it ) under the setting “Tools” ->” SDK Manager” -> “SDK Tools” tab.
Video Link - https://vimeo.com/manage/videos/739329236
Computer Specs -
I7 - 10750h,
Nvidia 1650 Ti - 4GB,
16 GB Ram,
1 TB SSD (443 GB free)
Also, I have noticed the screen goes most of the part blank when I am not touching the screen.

I had the same problem recently after create a emulator with API level 33,
Then I've tried to used API level 31 and emulator works normally.

I tried giving more memory to my emulator and the issue disappeared.
https://i.stack.imgur.com/QHSIK.png

It seems there is a problem with the x86_64 images. If Software GLESS is turned on then the flicker goes away but the graphics are little laggy.
x86 images works well smooth but out-dated.

I just installed Android Studio first time for a while and noticed the flickering problem right away. I have NVIDIA GPU which most likely contributes into this problem. In the AVD options inside the Android Studio device manager I tried switching the Graphics setting from automatic to "Software GLES 2.0" and it fixed the flickering. No way using software acceleration is optimal in any way but it could be a workaround until the root cause is fixed.
EDIT: found the issue posted about this behavior confirming it is a GPU driver related issue https://issuetracker.google.com/issues/246917660

I had a same issue in my new laptop. I have fixed it by changing one parameter in the emulator's config file.
Go to C:\Users\USER_NAME.android\avd\Pixel_5_API_31.avd
Edit the config.ini file.
Find the "hw.gpu.mode = auto" and change it to the "hw.gpu.mode = guest" and save the changes.
Restart the emulator.

Same here. After one of the latest Emulator (in SDK tools) updates virtual device with API level 31 or above show same issues. Devices with API level 30 or below work fine.
Tried to completely clean and re-install Studio and Video drivers. No effect.
So since it started right after update i believe it's Emulator component issue.

I just switched to a Pixel 5 with API 33 and it seems to have resolved my flickering problem..

Related

Why does latest Android Studio emulator crash or get stuck

Since I upgraded my Android Studio installation to Bumblebee, the emulator has become unusable. It either crashes during startup or gets itself stuck so that the UI is unresponsive and the debugger either cannot install or cannot launch an app. The way in which it fails varies from time to time for no reason that I can understand. although different virtual devices seem to behave differently. I tried deleting my old virtual devices and creating new ones, but that didn't help.
I can't debug my code on a real phone because of a different problem, see my recent answer to Source code does not match the bytecode for Android's View.java.
When it crashes I send a crash report to Google, but they don't seem to be fixing it. The problems started with the first official Bumblebee release 2021.1.1, which seemed to have a complete new version of the emulator, and I'm now on the latest stable version 2021.1.1 Patch 2.
My environment is a Dell Precision M4800 with 16GB of RAM and an 8-core Intel processor, using an external 4K monitor and an external full-size keyboard, running Linux openSUSE Leap 15.3 with all recommended patches installed.
Does anyone have any suggestion short of throwing away my entire Android Studio installation and reverting back to Arctic Fox? Has anyone else seen similar problems?
Tintin's answer didn't work for me: Device Frame wasn't enabled anyway because I had noticed that it had caused problems before.
However the following sequence rather surprisingly, at least to me, did fix the problem.
First make sure that the toolbar is visible at the top of the emulator window: if it isn't, click on the gear settings icon at the top right of the emulator window and enable Show Toolbar.
Start up an emulated virtual device, and before it crashes click on the three dots at the right hand end of the toolbar: this will bring up the extended controls window.
Choose Settings from the list at the left of the extended controls list.
Set the OpenGL ES renderer to Desktop native OpenGL, and the OpenGL ES API to Compatibility (OpenGL ES 1.1/2.0).
Close the extended controls window and then close the Android Emulator window.
Check if there are any zombie emulator or qemu processes still running. If there are, kill them: you'll need kill -9 on Linux.
Try to cold boot an emulated virtual device: it will probably crash before it even gets started up properly.
Close the Android Emulator window and repeat step 6
Try to cold boot an emulated virtual device again, but click on the three dots quickly before it crashes.
When the extended controls list comes up, choose Settings from the list at the left.
Set the OpenGL ES renderer back to SwiftShader, and the OpenGL ES API back to Renderer maximum (up to OpenGL ES 3.1).
Repeat steps 5 and 6.
Now try to boot up an emulated virtual device again. It should work: at least it does for me.
If it doesn't work on your configuration, try all possible combinations of the OpenGL ES settings: you may find one that works.
Logically, changing the OpenGL ES settings and then changing them back again shouldn't do anything, but it does. My guess is that perhaps some needed bit of initialisation for the OpenGL isn't being done by the installer, but it gets done when you change the configuration.
I also faced this problem in both updates in 2021.1.1 it was not working at all. Updated to patch 2 again faced problems turned off Enabled Device Frame it is working OK now

Multiple Android Studio lockups with Apple M1 chip

I have the MacBook Pro with the new M1 chip with 8GB ram running Big Sur V11.1 and Android Studio 4.1.2. Over the course of a couple hours of work in Android Studio I can get 4 or so spinning beachballs of death where I need to do a force quit and occasionally Android Studio blinks out of existence all together.
I am not using the emulator. The lockups always seem to occur while I am in the middle of editing code.
I have run the Mac in safe mode and that might have slowed down the frequency of lockups, but not eliminate them. (I am not keeping count.)
I did do a data migration from my old Mac (a 10yr old Intel machine that never had this problem, just got to be too slow). Don't know if that has anything to do with the problem.
The only good aspect is that the machine is fast so I have been submitting a crash report every time!
Just wondering if anyone has any words of wisdom to fix this.
Even with increased memory I faced similar issue. However managed to solve it by changing JDK used by Android Studio to M1 compatible JDK. I used Azul JDK.
Make sure to set both JAVA_HOME & STUDIO_JDK variables. Also change the project sdk to M1 compatible JDK.
I use Azul 15.0.2+7 ARM 64-bit macOS version.
Update 23 May 2021 ******
I've switched to latest intelliJ, which has M1 support and installed all android plugins. So far my experience has been exceptional. Debugging can get slow at times, but rest is just fine.
I had the same problem and after a little search i could fix it very easily...
The problem of crashing comes because is not allocated enough memory to the “JVM”.
Go to: Finder->Applications.
Right click on Android Studio. Select "Show package contents"
Go to : Contents->bin.
Right click on "studio.vmoptions". Select "open with"-> "textEdit".
Copy the Text somewhere for backup, just in case you mess it up.
Just change the numbers as shown on the 3 line below. Leave everything else as it is.
-Xmx6154m
-XX:MaxPermSize=1024m
-XX:ReservedCodeCacheSize=200m
That should fix the crashes.
I was facing the same issue, the way I solved this is I just deleted Android Studio and installed IntelliJ IDEA ultimate.
Jetbrains have an IntelliJ IDEA version special for M1 processor and it works like a charm on my MacBook Air (8gb RAM). The only downside is you can only use IntelliJ IDEA ultimate for free if you're a student, if you're not you'll only get one month of free trial.

Android studio emulator white screen

I've Installed the newest version of Android studio, including the newest version of HAXM, ndk, sdk and whatever other related dependencies it installs. Intel Virtualization bios setting thingy I can't remember the name of is enabled and I have no trouble in virtual box and such.
I created an empty activity and tried testing it on the phone, works perfectly. Then I tried it on the emulator and there is a problem when it is hardware accelerated. It just opens a white window. The android studio displays 0 errors and thinks it ran the app properly. The graphics card I have is a gtx 1060 6gb. When it is software accelerated it works but is so slow I would rather use a chisel on a rock to draw the application usage.
So if someone knows a fix it would be nice.
Thanks
Well I have discovered that in order to solve the issue you have to go to the sidebar menu click More>Settings>OpenGL ES Renderer and(in my case) set it to Angle(D3D11) or Angle(D3D9) or Swiftshader. After that you simply restart the emulator and the issue should be gone.
For me Desktop native OpenGL and Autodetect based on host(which probably sets it to the first thing) don't work and leave you with a white screen.
In case someone finds this useful, you can set software acceleration as below and this solved the issue for me on Mac OS. (OP also mentions it works with software acceleration)
Tools > AVD Manager
Select virtual device
Click on Edit (pencil icon for me)
Click "Show Advanced Settings"
Look for Emulated Performance - Graphics
Select "Software" option
Current version of the emulator (27.1.3) doesn't work for me. The emulator just shows a white screen. Even playing with the gpu in the .ini configuration didn't work.
Once I downgraded to 26.1.4 (https://dl.google.com/android/repository/emulator-darwin-4266726.zip) the emulator started working again.
It seems that the Android Emulator is somehow conflicting with the NVidia Web driver on Mac OS. I had the latest NVidia Web driver (378.05.05.25f04) installed and I was having this same problem - the white screen whenever I used Desktop Native rendering (or left it at the automatic default which selects that as well).
I tried the Swift Shader as well, it works but the performance is abysmal!
On a hunch, I switched back to the OS X Default Graphic Driver from the Nvidia Pref Pane in Apple menu settings, and the Desktop Native driver is now working great after the computer restart!
The same problem can happen to the lightning fast Microsoft Android Emulators utilizing Hyper-V that work on both Intel and AMD CPU based PCs. The solution is in the same line as the accepted answer. For those who use Microsoft Android Emulators and land here by searching "android emulator white screen", here is the screenshot showing how to solve the problem by changing the default hw.gpu.mode from the default "auto" to "mesa":
So sorry
Check your onCreate method in your MainActivity.java, it should have setContextView(R.layout.activity_main)

Process system isn't responding in android emulator

When I starts android emulator in android studio ; after boot completes this window opens :
and emulator hangs . How can I fix this problem ?
In my case, cold reboot resolves the issue on an OSX machine.
Close all open emulator first
Open android studio configure > avd manager
from the virtual device you are working on action > cold boot now
Hope the interface will be almost similar to Linux and Windows machine and the fix will workout there too.
I found some solutions in this page :
Error Message: emulator-arm.exe has stopped working
In this page suggests changing of resolution and RAM and you should decrease them.
When I decrease my resolution It fixes this problem .
Try to use a low-resolution device, when I selected Nexus 4 it kept running smoothly with me. If it doesn't work. try this:
If you want to have graphics acceleration enabled by default for this AVD, in the Hardware section of the AVD configuration, click New, select GPU emulation and set the value to Yes.
Beyond other possible solutions, what worked to me was to change the "Emulated performance" option to "Software".
I have tried changing the resolution, RAM size, Emulated performance graphic type, etc.. but none of them worked. Finally, I found that the android version image was my problem(Android P) so I downloaded a different version image and it worked fine
If the virtual device was previously working, try to wipe user data.
Go to the AVD manager, select the virtual device action and click on "Wipe data" (Wipe the user data of this AVD)
Here is how I fixed it:
In the AVD Manage-> Create Virtual Device... -> New Hardware Profile
Device Name: My Device
Resolution 800 x 600
RAM: 512 MB
Left other options as default -> Finish
Next -> Next (Or select API e.g R) -> Finish
That device never throws that error and works faster.
You can try doing cold reboot from Android Studio. It'll work normally then. I guess it usually happens when your PC/laptop goes into sleep mode, with emulator, debugger running in the background.
Solution 1:
Decrease API level resolves the issue on an Windows machine.
Solution 2:
Try to use a low-resolution device, If it doesn't work. try this:
If you want to have graphics acceleration enabled by default for this AVD, in the Hardware section of the AVD configuration, click New, select GPU emulation and set the value to Yes.
Solution 3:
Follow Steps:
Go to Device Manager
Select Wipe Data
Launch AVD again

AVD Emulator stuck on loading screen in Android Studio

I decided to try Android Studio 2.0 having used Eclipse in the past but I'm having considerable difficulty getting the AVD to load correctly. I've done quite a bit of googling and research into the problem, both here on SO and Google.So far nothing has worked.
The emulator simply hangs on the android load-up screen ever time I try to run it. I've seen it advised to use Genymotion but I would first prefer to resolve the issue natively in Android Studio to feel confident going forward using the IDE for building projects.
Here's what I've tried:
Complete reinstall of Android, SDK and SDK Tools
Install and configure of Intel x86 accelerator
Lowered the RAM amount to 512 in AVD settings
Multiple attempts at deleting and recreating AVD's
Tried creating different AVD phone models(Nexus One,Nexus 5x etc.)
Resetting ADB in AVD Monitor Tool
Starting ADB server from terminal
Restarting Android Studio multiple times after changes
Running SDK/SDK Tools updates several times
Made sure the SDK path is correct
These are the majority of the "solutions" I found either on other similar SO questions or by googling none of which has resolved the problem.
When I run the emulator currently it displays the following in the run window:
/Users/<username>/Library/Android/sdk/tools/emulator -netdelay none -netspeed full -avd Nexus_5X_API_23
Warning: requested ram_size 1024M too big, reduced to 512M
emulator: WARNING: Increasing RAM size to 1024MB
emulator: WARNING: VM heap size set below hardware specified minimum of 228MB
emulator: WARNING: Setting VM heap size to 256MB
Hax is enabled
Hax ram_size 0x20000000
HAX is working and emulator runs in fast virt mode.
console on port 5554, ADB on port 5555
The emulator shows up fine in the Android AVD Monitor devices pane and even appears to go through the entire booting process on the emulator screen itself but never gets to the Android home screen.
Also, Logcat seems to be looping continuously through dozens of errors and warnings, which don't offer any clear indication of what the issue might be or direction of how to resolve it.
I feel like I've exhausted every idea and not sure how to move forward.Just for the record, I am running El Capitan 10.9.2 with a 2.4gh Intel Core 2 Duo and 4gb ram.It's not the fastest machine for sure but should be capable of running Android Studio and the emulator.
Any help or guidance resolving this problem is gratefully appreciated!
For me this worked: in AVD(Tools->AVD) click on the small arrow for desired emulator then click on "Wipe data".
After that, it successfully started - passed the android logo screen - although a bit slowly.
You have two thing:
You should Increase your ADB emulator Heap to the minimum required.
in your case: 512M
into your AVD Manager:
Click Edit on your Emulator
"Show Advanced Settings" at the bottom
Go to: "Memory and Storage"
Edit the VM heap value to 512 MB
Finished
Image:
You can Wipe data to your Emulator. here is an exemple website
At one point my laptop hit a kernel panic and restarted while running an active AVD emulator session. When attempting to restart the emulator, the emulated device (Pixel 3) stayed stuck on the startup splash logo screen.
Fix steps:
Stop hung emulator session.
rm ~/.android/avd/name_of_emulated_device.avd/*.lock
rm ~/.android/avd/name_of_emulated_device.avd/*.qcow2
Restarting the emulated AVD should now be successful.
Windows equivalent for ~/.android should be C:\Users\.android, but I can't confirm this myself.
Note: You will likely lose any additionally installed apps and current work that was on the AVD.
Unfortunately, increasing the heap size didn't help in my case. The virtual device was actually running fine before with the previous amount of heap.
What I eventually ended up doing was just creating a new virtual device through the AVD manager leaving most of the fields the default value. The new device ran fine and booted up as expected and was able to run my app. It's possible something in my first virtual device became corrupted.
I had the same problem. I'm running El Capitan 10.11.5 with a 2.0GHz Intel Core 2 Duo and 8GB RAM, Android Studio 1.5.1.
After upgrading to Intel x86 Emulator Accelerator (HAXM Installer), rev 6.1.1 and deleting my API 14 SDK and related files, the newly installed API 23's Google APIs Intel x86 Atom System Image would not get past the Android logo screen.
After much trial & error, the Intel x86 Atom System Image (not Google APIs Intel x86 Atom System Image) for API 15 finally loaded the home screen on the emulator after ~ 8 min and one android system crash.
Will try the Intel x86 Atom System Image for API 23 later. Hope that helps.
I had the same problem and none of the steps listed here helped me, either.
But since the solution that worked for me was not mentioned here yet, I thought it might help you or one of the others finding this thread:
What did work for me was disabling certain settings in my Avast Antivirus as proposed by the Android studio troubleshooting page here.
My version of Avast did not have the setting "Use nested virtualization when available", however just turning off "Enable Hardware assisted virtualization" (note: restart is required for it to take effect) solved the problem just fine.
So if you are using Avast or another Antivirus which manipulates virtualization, be sure to look through the correspondent settings.
I had experienced same problem, What I did was, I clicked on the drop down in the actions column, then clicked on wipe Data, and that resolved it for me on ubuntu 20.04
I had this problem and running as admin fixed this (drove me crazy).
Hope this works for you too tried some many fixes.
What worked for me?
Create new project with same configs.
And start your old emulators in it.
What did not work?
Wiping data.
Increasing Heap size.
Creating new virtual device.
I also had the same problem with my AVD. After lots of trial and error I arrived at a solution for my problem. the problem was with the Heap size and the RAM size.
Initially the default heap size was 128 MB and RAM was 1563 , I just changed the heap size to 512 MB and reduced the RAM size( high RAM was making my pc run slow) also I enabled hardware acceleration. And Yipeee, it worked.
It's very easy to fix all you need to do is go in AVD Manager click on the small arrow on most right side of the screen beside the edit icon. Click that small arrow and select wipe data.
Now when you'll start your AVD it will restart and work properly.

Resources