gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 00:38:12 29 4
gpt4 key购买 nike

我不太确定在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/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com