java - android platfrom,Dalvik字节码或 native 机器码过程中的哪种代码?

标签 java android linux dalvik android-runtime

我不太确定在android平台上linux进程中加载​​了哪种代码。

如果android采用Dalvik,进程中包含一个Dalvik VM和应用程序的代码,代码是Dalvik字节码形式吗?如果是,那么代码和.apk文件中的classes.dex是一样的吗?

如果android采用Android Runtime (ART),由于classes.dex已经被翻译成native machine code,所以我认为app在Linux进程中的代码不会是Dalvik byte-codes,而是native machine code。如果我的理解是正确的,那么进程中是否还包含 Dalvik VM?

最佳答案

从 Android 5.0(Lollipop) 开始,Dalvik 已完全替换为 Android Runtime(ART) ,它处理原生二进制文件。

<子> Verifying App Behavior on the Android Runtime

The Android runtime (ART) is the default runtime for devices running Android 5.0 (API level 21) and higher.


At install time, ART compiles apps using the on-device dex2oat tool. This utility accepts DEX files as input and generates a compiled app executable for the target device

更具体地说,Dalvik 提倡使用 odex 文件,这些文件是 dex 文件的预处理优化版本,供 Dalvik 解释或 JIT 编译。

ART 提倡使用 ELF 文件,这是一种通用格式,可指导将某些功能和对象链接到设备的 native 指令,并在安装时执行。

<子> Wikipedia - Android Runtime

Unlike Dalvik, ART introduces the use of ahead-of-time (AOT) compilation by compiling entire applications into native machine code upon their installation.


ART uses the same input bytecode as Dalvik, supplied through standard .dex files as part of APK files, while the .odex files are replaced with Executable and Linkable Format (ELF) executables. Once an application is compiled by using ART's on-device dex2oat utility, it is run solely from the compiled ELF executable

<子> Executable and Linkable Format - Applications

Android uses ELF .so (shared object) libraries for the Java Native Interface. With Android Runtime (ART), the default since Android 5.0 "Lollipop", all applications are compiled into native ELF binaries on installation

ART 不包含 Dalvik 实例,尽管大部分兼容,但有人提到 ART 不支持 Dalvik 支持的某些功能。

<子> Verifying App Behavior on the Android Runtime

However, some techniques that work on Dalvik do not work on ART. This document lets you know about things to watch for when migrating an existing app to be compatible with ART. Most apps should just work when running with ART.

关于java - android platfrom,Dalvik字节码或 native 机器码过程中的哪种代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45951245/

相关文章:

java - Bash 命令检查 Linux 上是否安装了 Oracle 或 OpenJDK java 版本

Android webview后退按钮无法使用

android - 布局和 fragment 布局之间的区别

linux - sysenter_entry() : "movl (%ebp), %ebp" What is the meaning

java - 直到退出并再次运行应用程序后,服务才会启动 - Android

java - 我不提kafka是怎么决定分区的

java - 通过 JSON 发送 java.lang.Boolean (Spring Boot)

android - 默认共享首选项给我错误的服务值

linux - 如何设置PVM的环境?

php - 在 SLES-12-64 位 LINUX 上编译 php-5.2.8 时未找到配置 : error: png. h