Android Studio freezes entire computer upon pressing 'Play'? (Ubuntu) - android-studio

Pretty self-explanatory. Whenever I try to press 'play', as in the green play button to try and test run the app, my ENTIRE computer freezes. (Otherwise Android Studio seems to work fine, if a bit laggy.) I can't even move the cursor--even if I wait for more than fifteen minutes, it's frozen. The only option is to shut down the entire computer using the button on the outside of the computer. In my research, I couldn't find anything else with the same problem, let alone a solution.
I've tried installing an earlier version of android studio, but it did not help. Same problem. I'm thinking I might have to do a fresh install of Ubuntu and see if that works, which is a pain because I have GBs and GBs of data on this one. Help?
Specs: Running an Acer Aspire with 8GB of RAM, 64bit, Intel® Celeron(R) CPU N2840 # 2.16GHz × 2. Can't check the RAM at time of the error, because the entire computer gets frozen.

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 keeps freezing, crashing, and is not responding at all

I'm a starting Android development and have recently ran into some problems. I don't know whether it is my hardware or if it's Android Studio but the emulator keeps freezing or is not responding.
The first 2 days Android Studio was running fine. However, after that it cannot run my apps. I reinstalled Android Studio and it worked for one day, but now even if I reinstall it, it won't run any apps and even Android Studio itself would occasionally freeze and I will have to restart it.
The emulator either does this or does not even turn on:
it won't even respond when I click on anything on the emulator
Here is a break down of what's been happening.
Day 1: works fine.
Day 2: Android Studio freezes multiple times when I launch the emulator. Emulator unresponsive to clicks. I uninstall Android Studio thrn install it again. After reinstallation it works 100% again with the same app
Day 3: emulator unresponsive, freezes. Menu bottons such as rotate screen, back etc. unresponsive.
Day 4: same as day 3. Uninstall Android, reinstall. Unresponsive.
You can try changing this line of code System.out.println(userinput1); to Log.d(MainActivity.class.getSimpleName(), userinput1) because on emulator system.out.println() automatically redirects to logcat but sometimes not.
This problem may arise due to low ram size, android studio works fine with 8GB Ram.Or try to config emulator properly. Let me know if problem continues.
I would suggest that import just specific address of class not the whole package or as bundle.
With
import java.util.*;
all classes of java.util package is imported.
The problem might be that, your hardware might be overwhelmed.
I don't think anything is wrong with your code. What is your system configuration? Does other applications work on emulator work? Can you post you
post your logcat?
PS: I know it should have been a comment. But I don't have permissions, sorry.
Problem and solution
Same problem, unusable for serious testing, whole system locking up regularly (Linux Mint Vera | 16GB-RAM | Nvidia GP106 [GeForce GTX 1060 3GB] -- worked fine on Windows 7, exact same hardware (although hard drive config has changed slightly, might need to double-check the OS drive is connected port0 on motherboard in case of performance impact).
It's ironic that Android being Linux based, struggles to run in a Linux env xD.
Tried different:
Linux APIs
Emulator Phone Models
Phone RAM specs, processor specs, etc
( All different graphics modes (both in native A-Studio emulator and using the apt install-google-emulator option for vanilla standalone (old school) version. Old school version runs better (standalone version).
Checked all microcode updates and drivers are in order. (Using Nvidia GP106 [GeForce GTX 1060 3GB]
System is up to date (apt)
Found the best options:
Performance Better: Restart Android Emulated Device with 'Cold Boot' option specified
or
Use Diff Emulator: Virtual Machine Manager / Virsh (KVM-QEMU)
or
Use Physical Device: With Android 11+ you can wifi pair.
With devices APIs lower than 11, there is no Wi-Fi pair feature so I found solution was to install termux on the handset I wanted to use for app testing, which gave me a standardish shell with apt pkg manager -- then I could install sshd and connect to dev-PC with portforward i.e
$ SSH from Phone to PC with: ssh -R 4444:127.0.0.1:5555 ubuntu#192.168.1.20
$ SSH from PC to Phone with: ssh -L 4444:127.0.0.1:5555 ubuntu#192.168.1.20
(The exact command may vary, written from memory as quick guide to get you moving right direction thought ports are correct, syntax may need adjusting and of course, the username#hostIP needs setting to your you-login#your-computers--LAN-IP).
Once an SSH connection has been established, which you can check using something like
$ ss -tulpan | grep 4444
or
$ netstat -tulpan | grep 4444
Once confirmed established, you need to fire up adb to connect to the now available Android adb service that we forwarded from the handset into the dev-PC by running the command (also make sure you have USB debugging enabled on the handset before doing this);
On dev-PC run;
$ adb connect 127.0.0.1:4444
It should say 'CONNECTED'.
Then to double check, run:
$ adb devices
Emulator should show up in Android Studio Device Manager. Give it a few minutes and Android Studio will pick it up!
I can't remember the specific reason I needed to do it this way as opposed to just connecting with a USB cable. I think I was doing some mad routed setup. But there we have it!
I found using a physical device to be the ultimate performance solution but is of course a bulky arrangement.
Update
Increasing memory available to Android Studio and the VM made big difference (I have 16gb RAM).
Android Studio > Help > Change Memory Settings (2048 -> 4096)
Android Studio > Help > Edit Custom VM Options > add/replace-->
(-Xmx4096m
(-Xmx4096m
(Then finally added extra config to Gradle script to allow extra memory but I don't think that would have an impact on the slow running issue as was entire emulator crumbling not just the app.)
In gradle.properties, replace order.gradle.jvmargs.... (with)
org.gradle.jvmargs=-Xmx4096m -XX:MaxPermSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Finally, restart Android / Emulator and remember to do a COLD BOOT on your emulator device.

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.

Genymotion unstable

I've been using Genymotion, but its been pretty laggy. I only had HAXM accelerator installed so I decided to mess with VM manager, but it only seems to have made it worse. Now it runs smoothly but upon opening any application, it will either wait a bit then tell me the application isn't responding, or just freeze all together and give me a "player.exe has stopped working" dialog box. My changed system settings are as follows:
1 processor,
1024MB for the motherboard,
128MB for video with 3D acceleration enabled.
All other configurations are set to default.
I have an intel i5-2450M 2.5GHz chip with virtualization enabled in the BIOS.
Before when I had only HAXM installed, it worked fine. Just lagged a lot.
Help would be much appreciated.
You are using Windows 10?
Try to reinstall genymotion deleting all geny folders from your computer, remove virtualbox too.

Resources