ARChon is a little different than most of our best Android emulators for PC or Mac. Visual Studio now supports “FIPS compliance mode” Starting with version 16.4, Visual Studio 2019 now supports “FIPS 140-2 compliance mode” when developing apps and solutions for Windows, Azure, and.NET. When you’re developing apps or solutions for non-Microsoft platforms like Linux, iOS, or Android, these platforms may not use FIPS. If the Android emulator you are using is on older and unsupported Mac OS X version (10.9) then remember that you have to use older version of HAXM (6.1.2) also. If this is not used then its sure to come across apps keeps crashing issue. Solution 3: Antivirus Software. I'm using Android Studio 1.0.2 on a Mac. Joshua Mossop 885 Points. It 'runs' without errors but when it shows up on the emulator or my phone it immediately crashes. Charles Herrera 3,292 Points. I had to change the java to public class FunFactsActivity extends android.app.Activity. It would be nice to get someone from.
- Android Studio Emulator Crashes Mac Os
- Android Studio Emulator Crashes Mac Download
- Android Studio Emulator Crashes Machine
- Android Studio Emulator Crashes Mac
- Android Studio Emulator Crashes Mac Computer
An Android app crashes whenever there’s an unexpected exit caused by anunhandled exception or signal. An app that is written using Java or Kotlincrashes if it throws an unhandled exception, represented by theThrowable
class. Anapp that is written using native-code languages crashes if there’s an unhandledsignal, such as SIGSEGV, during its execution.
When an app crashes, Android terminates the app's process and displays a dialogto let the user know that the app has stopped, as shown in figure 1.
Figure 1. An app crash on an Android device
An app doesn’t need to be running in the foreground for it to crash. Any appcomponent, even components like broadcast receivers or content providers thatare running in the background, can cause an app to crash. These crashes areoften confusing for users because they were not actively engaging with your app.
If your app is experiencing crashes, you can use the guidance in this page todiagnose and fix the problem.
Detect the problem
You may not always know that your users are experiencing an inordinate number ofcrashes with your app. If you have already published your app, Android vitalscan help make you aware of the problem.
Android vitals
Android vitals can help improve your app's performance by alerting you, via thePlayConsole, when your app is exhibiting excessive crashes.Android vitals considers crashes excessive when an app:
- Exhibits at least one crash in at least 1.09% of its daily sessions.
- Exhibits two or more crashes in at least 0.18% of its daily sessions.
A daily session refers to a day in which your app was used.For information on how Google Play collects Android vitals data, see thePlay Console documentation.
After you learn that your app is suffering from too many crashes, thenext step is to diagnose them.

Diagnose the crashes
Solving crashes can be difficult. However, if you can identify the root cause ofthe crash, most likely you can find a solution to it.
There are many situations that can cause a crash in your app. Some reasons areobvious, like checking for a null value or empty string, but others are moresubtle, like passing invalid arguments to an API or even complex multithreadedinteractions.
Crashes on Android produce a stack trace, which is a snapshot of the sequence ofnested functions called in your program up to the moment it crashed. You canview crash stack traces inAndroid vitals.
Reading a stack trace
The first step to fix a crash is to identify the place where it happens. You canuse the stack trace available in the report details if you are using PlayConsole or the output of the logcat tool. If youdon’t have a stack trace available, you should locally reproduce the crash,either by manually testing the app or by reaching out to affected users, andreproduce it while using logcat.
The following trace shows an example of a crash on an app written using the Javaprogramming language:
A stack trace shows two pieces of information that are critical to debugging acrash:
- The type of exception thrown.
- The section of code where the exception is thrown.
The type of exception thrown is usually a very strong hint as to what wentwrong. Look at whether it is anIOException
, anOutOfMemoryError
,or something else, and find the documentation about the exception class.
The class, method, file, and line number of the source file where the exceptionis thrown is shown on the second line of a stack trace. For each function thatwas called, another line shows the preceding call site (called a stack frame).By walking up the stack and examining the code, you may find a place that ispassing an incorrect value. If your code doesn’t appear in the stack trace, itis likely that somewhere, you passed an invalid parameter into an asynchronousoperation. You can often figure out what happened by examining each line of thestack trace, finding any API classes that you used, and confirming that theparameters you passed were correct, and that you called it from a place that isallowed.
Stack traces for apps with C and C++ code work much the same way.
If you don't see class and function-level information in native stack traces,you may need togenerate a native debug symbols fileand upload it to the Google Play Console. For more information, seeDeobfuscate crash stack traces.For general information on native crashes, seeDiagnosing native crashes.
Tips for reproducing a crash
It’s possible that you can’t quite reproduce the problem just by starting anemulator or connecting your device to your computer. Development environmentstend to have more resources, such as bandwidth, memory, and storage. Use thetype of exception to determine what could be the resource that is scarce, orfind a correlation between the version of Android, device type or your app’sversion.
Memory errors
If you have anOutOfMemoryError
,then you could create an emulator with low memory capacity to test with. Figure2 shows the AVD manager settings where you can control the amount of memory onthe device.
Figure 2. Memory setting on AVD manager
Networking exceptions
Since users frequently move in and out of mobile or WiFi network coverage, in anapplication network exceptions usually should not be treated as errors, butrather as normal operating conditions that happen unexpectedly.
If you need to reproduce a network exception, such as anUnknownHostException
,then try turning on airplane mode while your application attempts to use thenetwork.
Another option is to reduce the quality of the network in the emulator bychoosing a network speed emulation and/or a network delay. You can use theSpeed and Latency settings on AVD manager, or you can start the emulatorwith the -netdelay
and -netspeed
flags, as shown in the followingcommand-line example:
This example sets a delay of 20 seconds on all network requests and an uploadand download speed of 14.4 Kbps. For more information on command-line optionsfor the emulator, seeStart the emulator from the command line.
Reading with logcat
Once you are able have the steps to reproduce the crash, you can use a tool likelogcat to get moreinformation.
The logcat output will show you what other log messages you have printed, alongwith others from the system. Don’t forget to turn off any extraLog
statements that youhave added because printing them wastes CPU and battery while your app isrunning.
Prevent crashes caused by null pointer exceptions
Null pointer exceptions (identified by the runtime error typeNullPointerException
) occur when you're trying to access an object that isnull, typically by invoking its methods or accessing its members. Null pointerexceptions are the largest cause of app crashes on Google Play. The purpose ofnull is to signify that the object is missing - for example, it hasn't beencreated or assigned yet. To avoid null pointer exceptions, you need to make surethat the object references you're working with are non-null before callingmethods on them or trying to access their members. If the object reference isnull, handle this case well (for example, exit from a method before performingany operations on the object reference and write information to a debug log).
Because you don't want to have null checks for every parameter of every methodcalled, you can rely on the IDE or on the type of the object to signifynullability.
Java programming language
The following sections apply to the Java programming language.
Compile time warnings
Annotate your methods' parameters and return values with@Nullable
and@NonNull
to receive compile timewarnings from the IDE. These warnings prompt you to expect a nullable object:
These null checks are for objects that you know could be null. An exception on a@NonNull
object is an indication of an error in your code that needs to beaddressed.
Compile time errors
Because nullability should be meaningful, you can embed it in the types you useso that there is a compile time check for null. If you know an object can benull and that nullability should be handled, you could wrap it in an object likeOptional
.You should always prefer types that convey nullability.
Kotlin
In Kotlin,nullability is part of the type system. For example, a variable needs to be declared fromthe beginning as nullable or non-nullable. Nullable types are marked with a ?
:
Non-nullable variables cannot be assigned a null value and nullable variablesneed to be checked for nullability before being used as non-null.
If you don't want to check for null explicitly, you can use the ?.
safe calloperator:
As a best practice, make sure you address the null case for a nullable object,or your app could get into unexpected states. If your application won't crashanymore with NullPointerException
, you won't know that these errors exist.
The following are some ways to check for null:
if
checksDue to smart-cast and the null check, the Kotlin compiler knows that thestring value is non-null so it allows you to use the reference directly,without the need for the safe call operator.
?:
Elvis operatorThis operator allows you to state 'if the object is non-null, return theobject; otherwise, return something else'.
You can still get a NullPointerException
in Kotlin. The following are the mostcommon situations:
- When you're explicitly throwing a
NullPointerException
. - When you're using thenull assertion
!!
operator.This operator converts any value to a non-null type, throwingNullPointerException
if the value is null. - When accessing a null reference of a platform type.
Platform types
Platform types are object declarations coming from Java.These types are specially-treated;null checks are not as enforced, so the non-null guarantee is the same as inJava. When you access a platform type reference, Kotlin does not create compiletime errors but these references can lead to runtime errors. See the followingexample from the Kotlin documentation:
Kotlin relies on type inference when a platform value is assigned to a Kotlinvariable, or you can define what type to expect. The best way to ensure thecorrect nullability state of a reference coming from Java is to use nullabilityannotations (for example, @Nullable
) in your Java code. The Kotlin compilerwill represent these references as actual nullable or non-nullable types, not asplatform types.
Java Jetpack APIs have been annotated with @Nullable
or @NonNull
as needed,and a similar approach has been taken in theAndroid 11 SDK.Types coming from this SDK, that are used in Kotlin, will be represented ascorrect nullable or non-nullable types.
Because of Kotlin's type system, we've seen apps have a major reduction inNullPointerException
crashes. For example, the Google Home app saw a 30%reduction in crashes caused by null pointer exceptions during the year that itmigrated new feature development to Kotlin.
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
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
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
.
Android Studio Emulator Crashes Mac Os
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.
- Quit Android Studio.
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.
- On Mac, this file should be in
Start Android Studio.
Getting 'No resource found that matches given name.'
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.
Android Studio Emulator Crashes Mac Download
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:
Android Studio Emulator Crashes Mac
First, try uninstalling the app from within the emulator and then restarting the emulator completely. Try debugging again now.
Next, close the emulator again and also restart Android Studio. Start Android Studio and reload the emulator. Then try debugging again.
If you are using official emulator, try using Genymotion or vice-versa. Then try debugging again.
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.