ART模式下dex2oat出错导致系统无法正常启动
Android4.4开始android的运行时出现了ART选项,以前只有Dalvik,也就是说android系统的虚拟机可以选择 Dalvik 也可以选择 ART,选择虚拟机的设置在 Developer options/Select Runtime 中完成
设置虚拟机的选项本质上只是改变一个系统属性的值,这个属性是 persist.sys.dalvik.vm.lib
app_process会创建android系统的第一个虚拟机。对于android系统的应用层和android系统的应用框架层来说,它们只知道有一个“虚拟机”,但是它们不需要知道这个虚拟机是ART还是Dalvik.
在app_process 创建虚拟机的过程中,libnativehelper 决定创建虚拟机的类型,具体的代码在libnativehelper/JniInvocation.cpp 中, 它根据persist.sys.dalvik.vm.lib 的值来决定是链接到libart.so 还是 libdvm.so.
如果选择ART的模式,在创建ART虚拟机的过程中会对framework 中的jar包进行 dex2oat,也就是 将framework 中的jar包 编译成 oat文件。在这个编译的过程中,虚拟机还没有处于运行的状态,如果编译的过程中 类的static{} 块和static 变量的初始化中存在 调用 native 的代码,那么会导致 dex2oat出现错误,系统无法正常启动,出现的log 一般如下所示
F/dex2oat ( 473): art/runtime/interpreter/interpreter.cc:223] Attempt to invoke native method in non-started runtime: boolean android.os.SystemProperties.native_get_boolean(java.lang.String, boolean)
F/dex2oat ( 473): art/runtime/runtime.cc:203] Runtime aborting...
F/dex2oat ( 473): art/runtime/runtime.cc:203] Aborting thread:
F/dex2oat ( 473): art/runtime/runtime.cc:203] "main" prio=5 tid=1 Runnable (still starting up)
F/dex2oat ( 473): art/runtime/runtime.cc:203] | group="" sCount=0 dsCount=0 obj=0x00000000 self=0x41ea9100
F/dex2oat ( 473): art/runtime/runtime.cc:203] | sysTid=473 nice=0 cgrp=default sched=0/0 handle=0x4009d154
F/dex2oat ( 473): art/runtime/runtime.cc:203] | state=R schedstat=( 18648884604 1281988401 114503 ) utm=1202 stm=662 core=3 HZ=100
F/dex2oat ( 473): art/runtime/runtime.cc:203] | stack=0xbe3b5000-0xbe3b9000 stackSize=8MB
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: art::Thread::DumpStack(std::ostream&) const+87 [0x403f4edc] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x403ed06c] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: art::Runtime::Abort()+79 [0x403ed5fc] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: art::LogMessage::~LogMessage()+505 [0x4029a93a] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x4031c4fc] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: artInterpreterToInterpreterBridge+307 [0x4032c140] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x4032c750] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x4032e5b6] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x40331bc2] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: art::interpreter::EnterInterpreterFromInvoke(art::Thread*, art::mirror::ArtMethod*, art::mirror::Object*, unsigned int*, art::JValue*)+603 [0x40338884] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: art::ClassLinker::InitializeClass(art::mirror::Class*, bool, bool)+1947 [0x402c3f70] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: art::ClassLinker::EnsureInitialized(art::mirror::Class*, bool, bool)+33 [0x402c415a] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: artInterpreterToInterpreterBridge+169 [0x4032c0b6] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x4032c750] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x4032e5b6] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x40331bc2] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: artInterpreterToInterpreterBridge+193 [0x4032c0ce] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x4032c750] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x4032e5b6] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x40331bc2] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: artInterpreterToInterpreterBridge+193 [0x4032c0ce] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x4032c750] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x4032cf28] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x403312ee] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: artInterpreterToInterpreterBridge+193 [0x4032c0ce] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x4032c750] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x4032da98] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x4033116a] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: art::interpreter::EnterInterpreterFromInvoke(art::Thread*, art::mirror::ArtMethod*, art::mirror::Object*, unsigned int*, art::JValue*)+603 [0x40338884] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: art::ClassLinker::InitializeClass(art::mirror::Class*, bool, bool)+1947 [0x402c3f70] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: art::ClassLinker::EnsureInitialized(art::mirror::Class*, bool, bool)+33 [0x402c415a] (libart.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] native: ??? [0x401ea69c] (libart-compiler.so)
F/dex2oat ( 473): art/runtime/runtime.cc:203] at android.os.SystemProperties.native_get_boolean(Native method)
F/dex2oat ( 473): art/runtime/runtime.cc:203] at android.os.SystemProperties.<clinit>(SystemProperties.java:39)
F/dex2oat ( 473): art/runtime/runtime.cc:203] - locked <0x42f71e88> (a java.lang.Class<android.os.SystemProperties>)
F/dex2oat ( 473): art/runtime/runtime.cc:203] at android.content.res.Configuration$Injector.setDefaultFontScale(Configuration.java:58)
F/dex2oat ( 473): art/runtime/runtime.cc:203] at android.content.res.Configuration.setToDefaults(Configuration.java:851)
F/dex2oat ( 473): art/runtime/runtime.cc:203] at android.content.res.Configuration.<init>(Configuration.java:643)
F/dex2oat ( 473): art/runtime/runtime.cc:203] at android.content.res.Configuration.<clinit>(Configuration.java:95)
F/dex2oat ( 473): art/runtime/runtime.cc:203] - locked <0x42e51070> (a java.lang.Class<android.content.res.Configuration>)
Attempt to invoke native method in non-started runtime 这句话的意思是 没有虚拟机的时候(虚拟机还没有开始运行),native 方法不能被执行。这个问题需要我们注意,为了保证ART模式的正常运行,在修改framework 代码的时候
1. 在类的static 代码块不能 调用 native 方法
2. 在类的static 变量初始化的时候不能调用 native 方法
上述的log 中我们可以看到 是 android.content.res.Configuration的static 代码块中调用了 native 方法 ,所以解决方案就是将 static 代码块中的native 部分修改。
ART模式下dex2oat出错导致系统无法正常启动相关推荐
- dvm,art模式下的dex文件加载流程
dvm,art模式下的dex文件加载流程 dex加载是学习android的重中之重,刚看完几篇参考博客,对应android源码,收益匪浅,用一篇博客总结一下自己学到的东西. 1.dvm模式下的dex加 ...
- android 5.0.1 libdvm.so,Android逆向进阶—— 脱壳的奥义(基ART模式下的dump)
本文作者:i春秋作家HAI_ZHU 0×00 前言 市面上的资料大多都是基于Dalvik模式的dump,所以这此准备搞一个ART模式下的dump. Dalvik模式是Android 4.4及其以下采用 ...
- Boot目录下内容丢失导致系统无法启动
Boot目录下内容丢失导致系统无法启动 笔者朋友近期在一次学习过程中不慎将虚拟机中boot目录下内容丢失,导致系统无法启动.当然此前他并不知道是这样,只是应为莫名的弹出框报错所有导致系统无法启动.此后 ...
- ART模式下基于Xposed Hook开发脱壳工具
本文博客地址:http://blog.csdn.net/qq1084283172/article/details/78092365 Dalvik模式下的Android加固技术已经很成熟了,Dalvik ...
- android+art模式死机,ADB命令解决切换ART模式后reboot无法进入系统循环卡屏教程
相信作为原生Android 4.4的一项特色功能,不少同学都会想要体验一下原汁原味ART模式吧.据说在ART模式下Android将不再卡顿,丝丝顺滑的流畅度直逼iOS.当然也有不少同学在把手机切换到A ...
- u盘如何在UEFI模式下用GHOST装系统
BIOS里设置成了UEFI启动模式,用普通的u盘启动发现进PE用GHOST装系统完成后启动不了. 一.BIOS设置启动模式. 1.legacy模式,也就是传统模式.在这种模式下,可以用各 ...
- 新零售边界的“突破”点是什么 新零售模式下新型供应链数字化系统怎么样?
新零售边界的"突破"点是什么?新零售模式下新型供应链数字化系统怎么样?看完易族智汇javashop为您编辑整理的您就会明白了,欢迎阅读,仅供参考. 新零售边界的"突破&q ...
- centos修改磁盘uuid_Centos更换损坏硬盘UUID改变导致系统不能正常启动处理
Centos 更换损坏硬盘 UUID 改变导致系统不能正常启动处理 一. 适用场景 本文档的适用场景为,更换硬盘导致系统启动时因 UUID 不同,导致 挂载文件读取失败, 系统不能正常启动, 同时本文 ...
- 修复错误配置fstab文件导致系统无法正常启动
修复错误配置fstab文件导致系统无法正常启动<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:off ...
- Springboot集成knife4j,Failed to start bean ‘documentationPluginsBootstrapper‘;导致系统不能正常启动
Springboot集成knife4j,Springboot更新到2.6启动报错Failed to start bean 'documentationPluginsBootstrapper'; nes ...
最新文章
- 正则词典 - 开源项目
- python 最小硬币数_程序以找到要在Python中达到目标的硬币组合数量
- python管理系统-员工管理系统源程序(python实现)
- 【Cocosd2d实例教程七】Cocos2d实现超炫的粒子效果!!
- python实现父类继承_Python多继承用super调用父类方法?
- 用matlab仿真pwm整流器的方法,MATLAB-PWM整流仿真模块建立详解.pdf
- 收藏:视频网站(JavaEE+FFmpeg)/Nginx+ffmpeg实现流媒体直播点播系统
- VirtualBox更改默认路径
- python使用redis_使用Redis和Python构建自行车共享应用
- 因果推断与反事实预测——几篇关联论文(二十六)
- 如何自动安装linux系统,Linux全自动安装操作实例
- Ajax中async与cache参数
- python标准库——sys模块
- Spring Data中什么是 Aggregate Roots
- 一张图读懂内存反碎片化
- 数据库学习总结(六)——查询练习题(1)
- Citrix Receiver 安装指南
- CentOS7.5安装oracle11g
- Docker基本操作五 (挂载数据卷)
- matlab画箱型图均值方差,Matlab 绘制箱线图