简而言之,不要在Android Gradle Build Plugin 3.0.x中使用D8。
我在我们的应用程序中的Lenovo P70-A上捕获了这个JIT编译器崩溃。在我们的情况下,错误是:
F/jazz (11964): mediatek/protect/dalvik/vm/jazz/dexlang/dex_lang-inl.h:2523] void jazz::DexLang<BitcodeGenerator>::EmitInstruction(const jazz::AIR&) [with BitcodeGenerator = jazz::dixieland::BitcodeGenerator] unimplemented not
E/dalvikvm(11964): VM aborting
F/libc (11964): Fatal signal 6 (SIGABRT) at 0x00002ebc (code=-6), thread 11970 (Compiler)
跟随崩溃转储:
I/DEBUG (12113): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG (12113): Build fingerprint: 'Lenovo/P70-A/P70-A:4.4.4/KOT49H/P70-A_S142_161230_16G_ROW:user/release-keys'
I/DEBUG (12113): pid: 11964, tid: 11970, name: Compiler >>> com.myapp <<<
I/DEBUG (12113): signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
I/DEBUG (12113): r0 00000000 r1 00002ec2 r2 00000006 r3 00000000
I/DEBUG (12113): r4 00000006 r5 00000000 r6 00002ec2 r7 0000010c
I/DEBUG (12113): r8 85d1ea6d r9 40159bd4 sl 76dd58ac fp 8283af64
I/DEBUG (12113): ip fffd1aa8 sp 76dd5630 lr 40109431 pc 40117dec cpsr 000f0010
I/DEBUG (12113):
I/DEBUG (12113): backtrace:
I/DEBUG (12113): #00 pc 00025dec /system/lib/libc.so (tgkill+12)
I/DEBUG (12113): #01 pc 0001742d /system/lib/libc.so (pthread_kill+64)
I/DEBUG (12113): #02 pc 00017625 /system/lib/libc.so (raise+10)
I/DEBUG (12113): #03 pc 0001633b /system/lib/libc.so
I/DEBUG (12113): #04 pc 0002569c /system/lib/libc.so (abort+4)
I/DEBUG (12113): #05 pc 0008a8fd /system/lib/libdvm.so (dvmAbort+80)
I/DEBUG (12113): #06 pc 0015a1e9 /system/lib/libdvm.so (jazz::LogMessage::~LogMessage()+576)
I/DEBUG (12113): #07 pc 0014f49d /system/lib/libdvm.so (jazz::DexLang<jazz::dixieland::BitcodeGenerator>::EmitInstruction(jazz::AIR const&)+1016)
I/DEBUG (12113): #08 pc 0014f60b /system/lib/libdvm.so (jazz::dixieland::Frontend::Compile(unsigned int, jazz::AIRMethod const&)+346)
I/DEBUG (12113): #09 pc 00153925 /system/lib/libdvm.so (jazz::dixieland::SubCompiler::Compile(unsigned int, jazz::AIRMethod const&)+32)
I/DEBUG (12113): #10 pc 00154443 /system/lib/libdvm.so (jazz::Jazz::Compile(jazz::CompilationUnit&)+126)
I/DEBUG (12113): #11 pc 00140d4d /system/lib/libdvm.so (jazz::Compiler::JitMethod(Method const&, jazz::jex::CompiledRawCode const*&, jazz::jex::CompiledRawCode const*&)+164)
I/DEBUG (12113): #12 pc 0011873d /system/lib/libdvm.so (jazzDoJITCompile(JitJazzMethodDescription const&, JitTranslationInfo&)+128)
I/DEBUG (12113): #13 pc 000f204f /system/lib/libdvm.so (dvmCompilerDoWork(CompilerWorkOrder*)+50)
I/DEBUG (12113): #14 pc 000d9f77 /system/lib/libdvm.so
I/DEBUG (12113): #15 pc 000a0485 /system/lib/libdvm.so
I/DEBUG (12113): #16 pc 0000d838 /system/lib/libc.so (__thread_entry+72)
I/DEBUG (12113):
I/DEBUG (12113): stack:
...
正如其他答案中所提到的,这是由D8实现引起的,它在Dalvik二进制代码中使用了not
指令,但是该设备上的JIT编译器不支持此指令。解决方案是通过从AGP 3.0.x的gradle.properties
中删除android.enableD8=true
来禁用编译中的D8。稳定版本的AGP 3.1将包含此问题的修复。
编辑:可能会在运行KitKat的搭载联发科SOC的设备上发生这种情况。