Android Studio Emulator Crashes Mac

Bluestacks is one of the most popular Android emulators for Windows and is. Android Emulator is included with Android Studio. Versions of the emulator prior to 25.3.0 were distributed as part of the Android SDK Tools. To ensure you have the latest version, check the SDK Manager for updates. For Android Emulator versions prior to 25.3.0, see the Android SDK Tools release notes.

This page will compile common issues experienced with Android Studio or above as they are experienced and recorded.

Debugging

If you want to do more in-depth debugging in your code, you can setup breakpoints in your code by clicking on the left side pane and then clicking on Run->Debug. You can also click on the bug icon if you've enabled the Toolbar (View->Enable Toolbar):

Android Studio also provides a built-in decompiler. You can also use Navigate->Declaration within the IDE and set breakpoints even within classes for which you may not necessarily have the actual source code. Notice the warning message at the top and an example of a screenshot of setting a breakpoint of a class defined in a JAR file below:

If the debugger isn't working, check the guide section below to get things running again.

Network Traffic Inspection

If you wish to inspect network traffic, see this guide on how to troubleshoot API calls. The networking library you use determines what approach you can use.

Database Inspection

Also, the Stetho project can be used to view your local SQLLite database. See this guide for more details.

LogCat

Android Studio contains a panel to receive logging messages from the emulator, known as LogCat. If you are not seeing any log messages, click on the Restart icon .

Resetting adb

If you are having issues trying to connect to the emulator or see any type of 'Connection refused' errors, you may need to reset the Android Debug Bridge. You can go to Tools->Android->Android Device Monitor. Click on the mobile device icon and click on the arrow facing down to find the Reset adb option.

Virtual Device Manager

Unable to delete emulator getting 'AVD is currently running in the Emulator'

Open the Tools => Android => AVD Manager and select virtual device that you want to delete. Click on the down arrow at the end and select the [Show on Disk] option which will open the emulator directory. Inside the [Your Device].avd folder, locate any *.lock files and delete them. You can now delete the emulator. See this stackoverflow post for more details.

Android Studio Issues

Crashes

Android Studio is Crashing or Freezing Up

If Android Studio starts freezing up or crashing even after rebooting the IDE or your computer, your Studio has likely become corrupted. The best way to resolve this is to clear all the caches by removing all the following folders:

and then uninstall Android Studio and re-install the latest stable version. This should allow you to boot Android Studio again without errors.

Android Studio Design Pane isn't loading properly

If you find yourself opening up a layout file and not seeing the design pane rendering correctly such as:

We can try the following steps to get this functioning again:

  • Try changing the API version selected in the dropdown and try a few different versions
  • Click the 'refresh' icon at the top right of the design pane
  • Select File -> Invalidate Caches / Restart and restart Android Studio

Android Studio Emulator Crashes Mac Computer

You may need to install the newest version of Android and select that version within the dropdown for the pane to work as expected.

Seeing Unable to execute dex: method ID when compiling

This might also show up as Too many field references: 131000; max is 65536. or com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536 or Error:Execution failed for task ':app:dexDebug' in the build console. This error occurs when the total number of references within a single bytecode file exceeds the 65,536 method limit. This usually means you have a substantial amount of code or are loading a large number of libraries.

If you've crossed this limit, this means you've loaded too many classes usually due to third-party libraries. Often the culprit is the Google Play Services library. Open up your app gradle file and look for this line implementation 'com.google.android.gms:play-services:X.X.X'. Remove that line and instead include the services selectively as outlined there. For example:

This can greatly reduce the number of classes loaded. If you've crossed the limit even with this change, we need to adjust our project to use a multidex configuration by enabling multiDexEnabled true in your gradle configuration and updating the application to extend from android.support.multidex.MultiDexApplication.

Seeing java.lang.OutOfMemoryError : GC overhead limit when compiling

You are most likely exhausting the heap size especially during compilation. Try to add inside this setting in your app/build.gradle:

You can also reduce the build time too by setting incremental to be true:

See this Google discussion article for more context.

Still not working? Try to increase the heap size of Android Studio.

  1. Quit Android Studio.
  2. Create or edit a studio.vmoptions file.

    • On Mac, this file should be in ~/Library/Preferences/AndroidStudio/studio.vmoptions.
    • On Windows, it should be in %USERPROFILE%.AndroidStudiostudio[64].exe.vmoptions.

    Increase the maximum memory to 2 Gb and max heap size of 1 Gb.

  3. Start Android Studio.

Getting 'No resource found that matches given name.'

Android Studio Emulator Crashes Mac

If you are using multiple layout folders and decide to rename any of your ID tags in your XML files, you may get 'No resource found that matches given name.' There is a current bug in how changes are detected in nested subfolders so your best option is to not use this approach until the problem is fixed. Otherwise, you will need to do a Rebuild Project so that the entire resource files can be regenerated and the build/ directories are fully removed. Note: Clean Project may not work.

Getting 'tooling.GradleConnectionException' errors

If you see org.gradle.tooling.GradleConnectionException errors, you may need to install a newer version of JDK (there have been reports of 1.7.0_71 having this issue). First try to restart the adb server first.

Getting 'failed to find Build Tools revision x.x.x'

If you're opening another Android Studio project and the project fails to compile, you may see 'failed to find Build Tools revision x.x.x' at the bottom of the screen. Since this package is constantly being changed, it should be no surprise that other people who have installed Android Studio may have different versions. You can either click the link below to install this specific Build Tools version, or you can modify the build.gradle file to match the version you currently have installed.

Getting 'com.android.dex.DexException: Multiple dex files define'

One of the issues in the new Gradle build system is that you can often get 'Multiple dex files define' issues.

If a library is included twice as a dependency you will encounter this issue. Review the libs folder for JARS and the gradle file at app/build.gradle and see if you can identify the library dependency that has been loaded into your application twice.

If one dependency library already includes an identical set of libraries, then you may have to make changes to your Gradle configurations to avoid this conflict. This problem usually happens when there are multiple third-party libraries integrated into your code base. See Must-Have-Libraries#butterknife-and-parceler for more information.

Another error if you attempt to include a library that is a subset of another library. For instance, suppose we included the Google play-services library but thought we also needed to include it with the play-services-map library.:

It turns out that having both is redundant and will cause errors. It is necessary in this case to remove one or the other, depending on your need to use other Google API libraries. See this overview of the multidex issue on the Android docs.

Seeing Unsupported major.minor version 52.0 on some plugins

Some Android Studio plugins do not support Java 1.6 anymore, so it's best to confirm what version you are using. Inside Android Studio, click on About Android Studio. You should see the JRE version listed as 1.x.x below:

If you have multiple Java versions installed, you should make sure that v1.6 is not being used. Solutions include:

  • Configuring JDK 8 as your default Java SDK within Studio. See this stackoverflow post for solutions.
  • Reset your Android Studio cache and set correct gradle version as shown in this post.

On OS X machines, you can remove the JDK from being noticed. You can move it the temporary directory in case other issues are created by this change.

INSTALL_FAILED_OLDER_SDK error message

If your minSdkVersion is higher than the Android version you are using (i.e. using an emulator that supports API 19 and your target version is for API 23), then you may see an error message that appears similar to the following:

You will need to either lower the minSdkVersion or upgrade to an Android emulator or device that supports the minimum SDK version required.

Android Studio Emulator Crashes Machine

Seeing java.lang.IllegalAccessError: Class ref in pre-verified class resolved to unexpected implementation

You have a third-party library reference defined twice. Check your app/build.gradle for duplicate libraries (i.e. commons-io library defined for 1.3 and another one using 2.4).

Debugger Isn't Working: Breakpoint In Thread is Not Hit

You might notice that the debugger does not always work as expected in background threads such as AsyncTask or when using networking libraries to send network requests. The debugger breakpoints are a little bit finicky when configured to stop outside the main thread.

In order for some of these breakpoints in the callbacks to work, you have to set them after the debugger has been initialized and not before. If you have already set the breakpoints before, then you have to reset them after the debugger starts. One common strategy is to set the breakpoint on the main thread and then, once that has been hit, add the breakpoint on the background thread.

Debugger Isn't Working: Disconnected or Client not ready yet

This is usually a signal that the emulator instance is not properly connected with ADB and Android Studio. There are a few steps to try:

  1. First, try uninstalling the app from within the emulator and then restarting the emulator completely. Try debugging again now.

  2. Next, close the emulator again and also restart Android Studio. Start Android Studio and reload the emulator. Then try debugging again.

  3. If you are using official emulator, try using Genymotion or vice-versa. Then try debugging again.

  4. Open up Tools => Android => Android SDK Manager and see if there are any updates to the platform or SDK tools. Update any suggested changes within the manager and then restart your emulator and Android Studio. Then try debugging again.

References

This page lists known issues, workarounds, and troubleshooting tips for theAndroid Emulator.

If you encounter an issue not listed here or are unable to successfully use aworkaround listed here, please report a bug.

Checking for adequate disk space

To avoid crashes and hangs caused by not having enough free disk space, theemulator checks for sufficient free disk space on startup, and will not startunless at least 2 GB is free. If the emulator fails to start for you, check tosee that you have adequate free disk space.

Antivirus software

Because many security and antivirus software packages work by monitoring everyread and write operation, use of such software can decrease performance of toolslike the Android Emulator.

Many antivirus packages provide the ability to add specific applications to alist of trusted applications, which enables these applications to operatewithout performance degradation. If you are experiencing poor performance withsaving or loading of AVD snapshots, you may improve this performance by addingthe Android Emulator application as a trusted application in your antivirussoftware.

The performance impact differs between various antivirus software packages. Ifyou have additional antivirus software installed beyond that which is includedwith your operating system, you can run simple tests to determine whichantivirus software has a greater performance effect on emulator load and saveoperations.

Some antivirus software may be incompatible with the Android Emulator.

If you're using Avast software and are having trouble running the AndroidEmulator, try disabling Use nested virtualization when availableand Enable Hardware assisted virtualization in the Avast Troubleshootingsettings. In addition, after Avast hardware virtualization is disabled, ensurethat HAXM is set up properly again with a full re-installation of the latest HAXMfrom the SDK Manager.

HAXM on older, unsupported versions of Mac OS

If you are using Android Emulator on older, unsupported versions of Mac OS X(such as 10.9), then you may need to use an older version of HAXM (6.1.2), too.

Android Emulator runs slowly after an update

A number of external factors can cause the Android Emulator to begin runningslowly after an update. To begin troubleshooting, we recommend thefollowing steps:

  • If you are running Android Emulator on Windows, check to see if you haveinstalled Windows UpdatesKB4013429andKB4015217.Some users reported improved Android Emulator performance after uninstallingthese updates. Users also reported improved Emulator performance afterinstalling Windows UpdateKB4015438.
  • If you have an Intel GPU (and in particular, the Intel HD 4000), ensure youhave downloaded and installed the latest Intel graphics driver.
  • If your machine has both an Intel HD 4000 GPU and a discrete GPU,disable the Intel HD 4000 GPU in Device Manager to ensure you areusing the discrete GPU.
  • Try running the emulator using the -gpu angle, -gpu swiftshader, or-gpu guest modes. For more information about configuring graphicsacceleration options on the command line, seeConfigure hardware acceleration.
  • Ensure that your router is not using IPv6 addresses if you do not have anIPv6 connection.

If you are still experiencing problems with the Android Emulator runningslowly, Report a bug, including thenecessary Android Emulator Details so we can investigate.

Windows: Free RAM and commit charge

When the emulator starts, it needs to initialize the Android guest operatingsystem's RAM. On Windows, the emulator asks Windows to account for the fullsize of guest memory at start time, even though during actual operation, thememory may be paged in on demand. The emulator requests the full amount of guestmemory at start time because Windows is conservative in ensuring that there isenough physical RAM and pagefile available to hold the entire potential workingset; this prepares for the worst case, in which all guest memory is touchedquickly, without any opportunity to discard or otherwise free memory.

Sometimes, when the emulator asks Windows to account for this full guest memorysize, the request exceeds the current commit limit, which is the total of theavailable physical RAM and pagefile. In this case, Windows can't guarantee thatthe worst-case working set will fit in either physical RAM or pagefile, and theemulator fails to start.

In typical cases, the amount of hard drive space allocated for the pagefile plusphysical RAM is more than enough for most use cases of the emulator. However, ifyou experience failures to start the emulator because of exceeding the commitlimit, we recommend examining the current commit charge, which can be seen inthe Performance tab in the Windows Task Manager. (To open the Task Manager,press Ctrl+Shift+Esc.)

You can lower the likelihood of exceeding the commit limit in various ways:

  • Free physical RAM before launching the emulator by closing unused applicationsand files.
  • Disable third-party memory management and memory compression utilities. Theseutilities can inefficiently cause an excess commit charge and bring yoursystem closer to the commit limit.
  • Use a system managed size for the Windows pagefile, which can more flexiblyand dynamically increase the pagefile size (and therefore the commit limit) inresponse to increased demand from the emulator and other applications.

    For more information on commit charges and why a flexible setting works best,see this Microsoft article.