Android 模拟器无法启动,陷入循环

Android emulator won't start, gets stuck in a loop

我知道 Android 模拟器存在很多问题,而且 Whosebug 几乎充满了关于它的问题。我知道,我已经经历了其中的大部分,以寻找我的问题的答案:)

我在开始时遇到了常见的 HAXM 问题,但我修复了 BIOS 中的 VT 设置并重新安装了 HAXM。

现在,当我通过 Android Studio 或命令行启动我的模拟器时,它无法启动并且卡在循环中。循环看起来像这样:

运行输出

Note: The environment variable $ANDROID_SDK_HOME is set, and the emulator uses that variable to locate AVDs.

This may result in the emulator failing to start if it cannot find the AVDs in the folder pointed to by the

given environment variable.

ANDROID_SDK_HOME=C:\Users\maffe

emulator: device fd:1160

HAXM is working and emulator runs in fast virt mode

emulator: warning: opening audio input failed

creating window 102 107 646 1147

emulator: UpdateCheck: current version '24.4.1', last version '24.4.1'

Logcat输出

01-22 05:48:36.770 6543-6543/? I/Netd: Netd 1.0 starting

01-22 05:48:36.771 6543-6543/? E/Netd: Failed to open /proc/sys/net/ipv6/conf/default/optimistic_dad: No such file or directory

01-22 05:48:36.771 6543-6543/? E/Netd: Failed to open /proc/sys/net/ipv6/conf/eth0/optimistic_dad: No such file or directory

01-22 05:48:36.771 6543-6543/? E/Netd: Failed to open /proc/sys/net/ipv6/conf/lo/optimistic_dad: No such file or directory

01-22 05:48:36.771 6543-6543/? E/Netd: Failed to open /proc/sys/net/ipv6/conf/sit0/optimistic_dad: No such file or directory

01-22 05:48:36.771 6543-6543/? E/Netd: Failed to open /proc/sys/net/ipv6/conf/default/use_optimistic: No such file or directory

01-22 05:48:36.771 6543-6543/? E/Netd: Failed to open /proc/sys/net/ipv6/conf/eth0/use_optimistic: No such file or directory

01-22 05:48:36.771 6543-6543/? E/Netd: Failed to open /proc/sys/net/ipv6/conf/lo/use_optimistic: No such file or directory

01-22 05:48:36.772 6543-6543/? E/Netd: Failed to open /proc/sys/net/ipv6/conf/sit0/use_optimistic: No such file or directory

01-22 05:48:36.875 6544-6544/? I/mediaserver: ServiceManager: 0xb5835620

01-22 05:48:36.875 6544-6544/? I/AudioFlinger: Using default 3000 mSec as standby time.

01-22 05:48:36.876 6544-6544/? I/ServiceManager: Waiting for service batterystats...

01-22 05:48:36.903 6545-6545/? D/AndroidRuntime: >>>>>> START com.android.internal.os.ZygoteInit uid 0 <<<<<<

01-22 05:48:36.904 6545-6545/? D/AndroidRuntime: CheckJNI is ON

01-22 05:48:36.904 6545-6545/? I/art: option[0]=-Xzygote

01-22 05:48:36.904 6545-6545/? I/art: option[1]=-Xcheck:jni

01-22 05:48:36.904 6545-6545/? I/art: option[2]=-Xjnigreflimit:2000

01-22 05:48:36.904 6545-6545/? I/art: option[3]=-Xstacktracefile:/data/anr/traces.txt

01-22 05:48:36.904 6545-6545/? I/art: option[4]=exit

01-22 05:48:36.904 6545-6545/? I/art: option[5]=vfprintf

01-22 05:48:36.904 6545-6545/? I/art: option[6]=sensitiveThread

01-22 05:48:36.904 6545-6545/? I/art: option[7]=-verbose:gc

01-22 05:48:36.904 6545-6545/? I/art: option[8]=-Xms4m

01-22 05:48:36.904 6545-6545/? I/art: option[9]=-Xmx2048m

01-22 05:48:36.904 6545-6545/? I/art: option[10]=-XX:mainThreadStackSize=24K

01-22 05:48:36.905 6545-6545/? I/art: option[11]=-agentlib:jdwp=transport=dt_android_adb,suspend=n,server=y

01-22 05:48:36.905 6545-6545/? I/art: option[12]=-Xlockprofthreshold:500

01-22 05:48:36.905 6545-6545/? I/art: option[13]=-Ximage-compiler-option

01-22 05:48:36.905 6545-6545/? I/art: option[14]=--runtime-arg

01-22 05:48:36.905 6545-6545/? I/art: option[15]=-Ximage-compiler-option

01-22 05:48:36.905 6545-6545/? I/art: option[16]=-Xms64m

01-22 05:48:36.905 6545-6545/? I/art: option[17]=-Ximage-compiler-option

01-22 05:48:36.905 6545-6545/? I/art: option[18]=--runtime-arg

01-22 05:48:36.905 6545-6545/? I/art: option[19]=-Ximage-compiler-option

01-22 05:48:36.905 6545-6545/? I/art: option[20]=-Xmx64m

01-22 05:48:36.905 6545-6545/? I/art: option[21]=-Ximage-compiler-option

01-22 05:48:36.905 6545-6545/? I/art: option[22]=--image-classes=/system/etc/preloaded-classes

01-22 05:48:36.905 6545-6545/? I/art: option[23]=-Xcompiler-option

01-22 05:48:36.905 6545-6545/? I/art: option[24]=--runtime-arg

01-22 05:48:36.905 6545-6545/? I/art: option[25]=-Xcompiler-option

01-22 05:48:36.905 6545-6545/? I/art: option[26]=-Xms64m

01-22 05:48:36.905 6545-6545/? I/art: option[27]=-Xcompiler-option

01-22 05:48:36.905 6545-6545/? I/art: option[28]=--runtime-arg

01-22 05:48:36.905 6545-6545/? I/art: option[29]=-Xcompiler-option

01-22 05:48:36.905 6545-6545/? I/art: option[30]=-Xmx512m

01-22 05:48:36.905 6545-6545/? I/art: option[31]=-Duser.language=en

01-22 05:48:36.905 6545-6545/? I/art: option[32]=-Duser.region=US

01-22 05:48:36.917 6545-6545/? W/art: Incomplete boot detected. Pruning dalvik cache

01-22 05:48:36.924 6545-6545/? I/art: Pruning dalvik-cache since we are relocating an image and will need to recompile

01-22 05:48:36.924 6545-6545/? I/art: RelocateImage: /system/bin/patchoat --input-image-location=/system/framework/boot.art --output-image-file=/data/dalvik-cache/x86/system@framework@boot.art --input-oat-location=/system/framework/boot.oat --output-oat-file=/data/dalvik-cache/x86/system@framework@boot.oat --instruction-set=x86 --base-offset-delta=-2789376

01-22 05:48:37.886 6544-6544/? I/ServiceManager: Waiting for service batterystats...

01-22 05:48:38.558 6543-6543/? V/NatController: runCmd(/system/bin/iptables -F natctrl_FORWARD) res=0

01-22 05:48:38.576 6543-6543/? V/NatController: runCmd(/system/bin/iptables -A natctrl_FORWARD -j DROP) res=0

01-22 05:48:38.578 6543-6543/? V/NatController: runCmd(/system/bin/iptables -t nat -F natctrl_nat_POSTROUTING) res=0

01-22 05:48:38.606 6543-6543/? V/NatController: runCmd(/system/bin/iptables -F natctrl_tether_counters) res=0

01-22 05:48:38.608 6543-6543/? V/NatController: runCmd(/system/bin/iptables -X natctrl_tether_counters) res=0

01-22 05:48:38.636 6543-6543/? V/NatController: runCmd(/system/bin/iptables -N natctrl_tether_counters) res=0

01-22 05:48:38.633 6698-6698/? W/iptables: type=1400 audit(0.0:151): avc: denied { module_request } for kmod="ipt_TCPMSS" scontext=u:r:netd:s0 tcontext=u:r:kernel:s0 tclass=system permissive=0

01-22 05:48:38.639 6543-6543/? V/NatController: runCmd(/system/bin/iptables -t mangle -A natctrl_mangle_FORWARD -p tcp --tcp-flags SYN SYN -j TCPMSS --clamp-mss-to-pmtu) res=1

01-22 05:48:38.896 6544-6544/? I/ServiceManager: Waiting for service batterystats...

01-22 05:48:39.183 6745-6745/? W/iptables: type=1400 audit(0.0:152): avc: denied { module_request } for kmod="ipt_owner" scontext=u:r:netd:s0 tcontext=u:r:kernel:s0 tclass=system permissive=0

01-22 05:48:39.183 6745-6745/? W/iptables: type=1400 audit(0.0:153): avc: denied { module_request } for kmod="ipt_owner" scontext=u:r:netd:s0 tcontext=u:r:kernel:s0 tclass=system permissive=0

01-22 05:48:39.183 6745-6745/? W/iptables: type=1400 audit(0.0:154): avc: denied { module_request } for kmod="ipt_owner" scontext=u:r:netd:s0 tcontext=u:r:kernel:s0 tclass=system permissive=0

01-22 05:48:39.188 6543-6543/? I/iptables: iptables: No chain/target/match by that name.

01-22 05:48:39.196 6543-6543/? I/iptables: iptables terminated by exit(1)

01-22 05:48:39.197 6543-6543/? E/BandwidthController: runIptablesCmd(): res=1 status=256 failed /system/bin/iptables -A bw_INPUT -m owner --socket-exists

01-22 05:48:39.193 6746-6746/? W/ip6tables: type=1400 audit(0.0:155): avc: denied { module_request } for kmod="ip6t_owner" scontext=u:r:netd:s0 tcontext=u:r:kernel:s0 tclass=system permissive=0

01-22 05:48:39.193 6746-6746/? W/ip6tables: type=1400 audit(0.0:156): avc: denied { module_request } for kmod="ip6t_owner" scontext=u:r:netd:s0 tcontext=u:r:kernel:s0 tclass=system permissive=0

01-22 05:48:39.193 6746-6746/? W/ip6tables: type=1400 audit(0.0:157): avc: denied { module_request } for kmod="ip6t_owner" scontext=u:r:netd:s0 tcontext=u:r:kernel:s0 tclass=system permissive=0

01-22 05:48:39.202 6543-6543/? I/ip6tables: ip6tables: No chain/target/match by that name.

01-22 05:48:39.202 6543-6543/? I/ip6tables: ip6tables terminated by exit(1)

01-22 05:48:39.203 6543-6543/? E/BandwidthController: runIptablesCmd(): res=1 status=256 failed /system/bin/ip6tables -A bw_INPUT -m owner --socket-exists

01-22 05:48:39.216 6747-6747/? E/logwrapper: executing /system/bin/ip failed: No such file or directory

01-22 05:48:39.228 6543-6543/? E/Netd: failed to flush rules

01-22 05:48:39.228 6543-6543/? E/CommandListener: failed to initialize RouteController (Remote I/O error)

01-22 05:48:39.229 6543-6543/? D/MDnsDS: MDnsSdListener::Hander starting up

01-22 05:48:39.229 6543-6752/? D/MDnsDS: MDnsSdListener starting to monitor

01-22 05:48:39.230 6543-6752/? D/MDnsDS: Going to poll with pollCount 1

01-22 05:48:39.907 6544-6544/? I/ServiceManager: Waiting for service batterystats...

01-22 05:48:40.357 6545-6545/? A/art: art/runtime/gc/heap.cc:293] Check failed: main_mem_map_1.get() != nullptr Failed anonymous mmap(0x0, -2147483648, 0x3, 0x2, 4, 0): Out of memory

01-22 05:48:40.357 6545-6545/? A/art: art/runtime/gc/heap.cc:293] 6fd57000-706cd000 rw-p 00000000 1f:01 7051
/data/dalvik-cache/x86/system@framework@boot.art

01-22 05:48:40.357 6545-6545/? A/art: art/runtime/gc/heap.cc:293] 706cd000-7215f000 r--p 00000000 1f:01 7052
/data/dalvik-cache/x86/system@framework@boot.oat

01-22 05:48:40.357 6545-6545/? A/art: art/runtime/gc/heap.cc:293] 7215f000-73b89000 r-xp 01a92000 1f:01 7052
/data/dalvik-cache/x86/system@framework@boot.oat

01-22 05:48:40.357 6545-6545/? A/art: art/runtime/gc/heap.cc:293] 73b89000-73b8a000 rw-p 034bc000 1f:01 7052
/data/dalvik-cache/x86/system@framework@boot.oat

01-22 05:48:40.357 6545-6545/? A/art: art/runtime/gc/heap.cc:293] 73b8a000-77b8a000 rw-p 00000000 00:04 16488
/dev/ashmem/dalvik-zygote space (deleted)

01-22 05:48:40.357 6545-6545/? A/art: art/runtime/gc/heap.cc:293] b3ab5000-b3adb000 r--p 00976000 1f:01 7051
/data/dalvik-cache/x86/system@framework@boot.art

01-22 05:48:40.357 6545-6545/? A/art: art/runtime/gc/heap.cc:293] b3adb000-b3adc000 r-xp 00000000 1f:00 898
/system/lib/libsigchain.so

... (for brevity)

01-22 05:48:40.415 6545-6545/? A/art: art/runtime/gc/heap.cc:293] b7780000-b7781000 r-xp 00000000 00:00 0 [vdso]

01-22 05:48:40.415 6545-6545/? A/art: art/runtime/gc/heap.cc:293] b7781000-b7782000 r--p 00016000 1f:00 258 /system/bin/linker

01-22 05:48:40.415 6545-6545/? A/art: art/runtime/gc/heap.cc:293] b7782000-b7783000 rw-p 00017000 1f:00 258 /system/bin/linker

01-22 05:48:40.415 6545-6545/? A/art: art/runtime/gc/heap.cc:293] b7783000-b7784000 rw-p 00000000 00:00 0

01-22 05:48:40.415 6545-6545/? A/art: art/runtime/gc/heap.cc:293] b7784000-b7788000 r-xp 00000000 1f:00 194
/system/bin/app_process32

01-22 05:48:40.415 6545-6545/? A/art: art/runtime/gc/heap.cc:293] b7788000-b7789000 r--p 00003000 1f:00 194
/system/bin/app_process32

01-22 05:48:40.415 6545-6545/? A/art: art/runtime/gc/heap.cc:293] b7789000-b778a000 rw-p 00000000 00:00 0

01-22 05:48:40.417 6545-6545/? A/art: art/runtime/gc/heap.cc:293] bff3f000-bff60000 rw-p 00000000 00:00 0 [stack]

01-22 05:48:40.417 6545-6545/? A/art: art/runtime/gc/heap.cc:293]

01-22 05:48:40.421 6545-6545/? A/art: art/runtime/runtime.cc:289] Runtime aborting...

01-22 05:48:40.422 6545-6545/? A/art: art/runtime/runtime.cc:289] (Aborting thread was not attached to runtime!)

01-22 05:48:40.422 6545-6545/? A/art: art/runtime/runtime.cc:289]
native: #00 pc 00005d03 /system/lib/libbacktrace_libc++.so (UnwindCurrent::Unwind(unsigned int, ucontext*)+83)

01-22 05:48:40.422 6545-6545/? A/art: art/runtime/runtime.cc:289]
native: #01 pc 00003051 /system/lib/libbacktrace_libc++.so (Backtrace::Unwind(unsigned int, ucontext*)+33)

01-22 05:48:40.422 6545-6545/? A/art: art/runtime/runtime.cc:289]
native: #02 pc 003c9e67 /system/lib/libart.so (art::DumpNativeStack(std::__1::basic_ostream >&, int, char const*, art::mirror::ArtMethod*)+135)

01-22 05:48:40.422 6545-6545/? A/art: art/runtime/runtime.cc:289]
native: #03 pc 003777cb /system/lib/libart.so (art::AbortState::Dump(std::__1::basic_ostream >&)+267)

01-22 05:48:40.424 6545-6545/? A/art: art/runtime/runtime.cc:289]
native: #04 pc 00377ead /system/lib/libart.so (art::Runtime::Abort()+125)

01-22 05:48:40.424 6545-6545/? A/art: art/runtime/runtime.cc:289]
native: #05 pc 000ec704 /system/lib/libart.so (art::LogMessage::~LogMessage()+1876)

01-22 05:48:40.424 6545-6545/? A/art: art/runtime/runtime.cc:289]
native: #06 pc 001ec6cc /system/lib/libart.so (art::gc::Heap::Heap(unsigned int, unsigned int, unsigned int, unsigned int, double, double, unsigned int, unsigned int, std::__1::basic_string, std::__1::allocator > const&, art::InstructionSet, art::gc::CollectorType, art::gc::CollectorType, unsigned int, unsigned int, bool, unsigned int, unsigned int, bool, bool, bool, bool, bool, bool, bool, bool, bool, unsigned long long)+10476)

01-22 05:48:40.424 6545-6545/? A/art: art/runtime/runtime.cc:289]
native: #07 pc 0037a32b /system/lib/libart.so (art::Runtime::Init(std::__1::vector, std::__1::allocator >, void const*>, std::__1::allocator, std::__1::allocator >, void const*>

const&, bool)+1387)

01-22 05:48:40.424 6545-6545/? A/art: art/runtime/runtime.cc:289]
本机:#08 pc 0037d6a8 /system/lib/libart.so (art::运行time::Create(std::__1::vector, std::__1::allocator >, void 常量*>, std::__1::allocator, std::__1::allocator >, void const*>

const&, bool)+104)

01-22 05:48:40.424 6545-6545/? A/art: art/runtime/runtime.cc:289]
本机:#09 pc 002ff0fd /system/lib/libart.so (JNI_CreateJavaVM+1117)

01-22 05:48:40.424 6545-6545/? A/art: art/runtime/runtime.cc:289]
原生:#10 pc 00072bfa /system/lib/libandroid_runtime.so (android::Android运行time::startVm(_JavaVM**, _JNIEnv**, bool)+2346)

01-22 05:48:40.424 6545-6545/? A/art: art/runtime/runtime.cc:289]
本机:#11 pc 00073a80 /system/lib/libandroid_runtime.so (android::Android运行time::start(char const*, android::Vector const&, bool)+368)

01-22 05:48:40.424 6545-6545/? A/art: art/runtime/runtime.cc:289]
本机:#12 pc 000018b1 /system/bin/app_process32 (???)

01-22 05:48:40.424 6545-6545/? A/art: art/runtime/runtime.cc:289]
本机:#13 pc 00012f94 /system/lib/libc.so (__libc_init+100)

01-22 05:48:40.424 6545-6545/? A/art: art/runtime/runtime.cc:289]
本机:#14 pc 00001b66 /system/bin/app_process32 (???)

01-22 05:48:40.426 6545-6545/? A/art: art/runtime/runtime.cc:289]
本机:#15 pc 00000004 ???

01-22 05:48:40.426 6545-6545/? A/art: art/runtime/runtime.cc:289] 转储所有未持有适当锁的线程:线程列表锁 突变锁

01-22 05:48:40.426 6545-6545/? A/art: art/runtime/runtime.cc:289] 全部 线程:

01-22 05:48:40.426 6545-6545/? A/art: art/runtime/runtime.cc:289] DALVIK 线程 (0):

01-22 05:48:40.426 6545-6545/? A/art: art/runtime/runtime.cc:289]

01-22 05:48:40.426 6545-6545/? A/libc:致命信号 6 (SIGABRT),代码 -6 in tid 6545(合子)

01-22 05:48:40.547 939-939/? I/DEBUG: * *


01-22 05:48:40.547 939-939/? I/DEBUG:构建指纹: 'Android/sdk_google_phone_x86/generic_x86:5.1.1/LMY48X/2524186:userdebug/test-keys'

01-22 05:48:40.547 939-939/? I/DEBUG:修订:'0'

01-22 05:48:40.547 939-939/? I/DEBUG:ABI:'x86'

01-22 05:48:40.547 939-939/? I/DEBUG: pid: 6545, tid: 6545, 名称: 合子 >>> 合子 <<<

01-22 05:48:40.547 939-939/? I/DEBUG:信号 6 (SIGABRT),代码 -6 (SI_TKILL), 故障地址--------

01-22 05:48:40.551 939-939/? I/DEBUG:中止消息: 'art/runtime/gc/heap.cc:293] 检查失败:main_mem_map_1.get() != nullptr 失败的匿名 mmap(0x0, -2147483648, 0x3, 0x2, 4, 0): Out 内存'

01-22 05:48:40.551 939-939/? I/DEBUG: eax 00000000 ebx 00001991 ecx 00001991 edx 00000006

01-22 05:48:40.552 939-939/? I/DEBUG: esi b7782c48 edi 0000000c

01-22 05:48:40.552 939-939/? I/DEBUG: xcs 00000073 xds 0000007b xes 0000007b xfs 00000000 xss 0000007b

01-22 05:48:40.552 939-939/? I/DEBUG: eip b750fd86 ebp 00001991 esp bff5d8b0 标志 00000286

01-22 05:48:40.552 939-939/? I/DEBUG:#00 个 00073d86 /system/lib/libc.so (tgkill+22)

01-22 05:48:40.552 939-939/? I/DEBUG:#01 件 0002217b /system/lib/libc.so (pthread_kill+155)

01-22 05:48:40.552 939-939/? I/DEBUG:#02 件 000239f4 /system/lib/libc.so (加注+36)

01-22 05:48:40.552 939-939/? I/DEBUG:#03 件 0001bdf4 /system/lib/libc.so (中止+84)

01-22 05:48:40.552 939-939/? I/DEBUG:#04 件 00377f56 /system/lib/libart.so (艺术::运行时间::中止()+294)

01-22 05:48:40.553 939-939/? I/DEBUG:#05 件 000ec704 /system/lib/libart.so (art::LogMessage::~LogMessage()+1876)

01-22 05:48:40.553 939-939/? I/DEBUG:#06 件 001ec6cc /system/lib/libart.so (art::gc::Heap::Heap(unsigned int, unsigned int, 无符号整数,无符号整数,双精度,双精度,无符号整数,无符号 整数,std::__1::basic_string, std::__1::allocator > const&, art::InstructionSet, art::gc::CollectorType, art::gc::CollectorType, 无符号整型, 无符号 整数,布尔值,无符号整数,无符号整数,布尔值,布尔值,布尔值,布尔值,布尔值, bool, bool, bool, bool, unsigned long long)+10476)

01-22 05:48:40.553 939-939/? I/DEBUG:#07 件 0037a32b /system/lib/libart.所以 (art::运行time::Init(std::__1::vector, std::__1::allocator >, void 常量*>, std::__1::allocator, std::__1::allocator >, void const*>

const&, bool)+1387)

01-22 05:48:40.553 939-939/? I/DEBUG:#08 件 0037d6a8 /system/lib/libart.所以 (art::运行time::Create(std::__1::vector, std::__1::allocator >, void 常量*>, std::__1::allocator, std::__1::allocator >, void const*>

const&, bool)+104)

01-22 05:48:40.553 939-939/? I/DEBUG:#09 个人电脑 002ff0fd /system/lib/libart.so (JNI_CreateJavaVM+1117)

01-22 05:48:40.553 939-939/? I/DEBUG:#10 件 00072bfa /system/lib/libandroid_runtime.所以 (android::Android运行time::startVm(_JavaVM**, _JNIEnv**, bool)+2346)

01-22 05:48:40.553 939-939/? I/DEBUG:#11 件 00073a80 /system/lib/libandroid_runtime.so (android::Android运行time::start(char 常量*, android::Vector 常量&, 布尔)+368)

01-22 05:48:40.553 939-939/? I/DEBUG:#12 件 000018b1 /system/bin/app_process32

01-22 05:48:40.553 939-939/? I/DEBUG:#13 件 00012f94 /system/lib/libc.so (__libc_init+100)

01-22 05:48:40.553 939-939/? I/DEBUG:#14 件 00001b66 /system/bin/app_process32

01-22 05:48:40.554 939-939/? I/DEBUG:#15 件 00000004

01-22 05:48:40.627 929-929/? I/ServiceManager: 服务 'media.audio_flinger' 去世

我的 .avd 文件夹位于 C:\Users\maffe,您可以看到 HAXM 正在运行。

我的模拟器设备是:

我本人运行以下电脑:

知道为什么它会卡在 Logcat 输出中显示的循环中吗?我所看到的只是带有 'Android' 标志的黑屏(当然,如果我取消选中“使用主机 GPU”,这比我得到的纯黑屏要好)。

我发现了问题。我不小心将 VM 堆 设置为 2GB。我应该把它留在 64MB :)

模拟器可能 运行 内存不足。降低 AVD 管理器中的 VM 堆或内存选项。那对我有用。循环出现 nullptr Failed anonymous mmap 错误时。

我手动 运行 HAXM 安装程序,路径:

C:\users\username\appdata\local\android\sdk\extras\intel\hardware_accelarated_execution_management\

运行 .exe 文件。