Android 2.1 (Eclair) 的 .dex 文件格式,即 API 级别 7

Format of .dex files for Android 2.1 (Eclair), i.e. API level 7

我是 writing an assembler for Android/Dalvik .dex files. The official Android docs seem to only describe the newest version of the .dex format (apparently 038 as of May 2019), with a few short notes describing differences back to version 035. A quick glimpse into Android sources seems to suggest, that version 035 of the format corresponds to Android API level 13, meaning Android 3.2.x (Honeycomb). I own a device with Android 2.1 (Eclair), which apparently 表示 API 7 级 。我希望能够学习如何为该设备发出正确的 .dex 和 .apk 文件,希望为我的汇编程序添加对这些文件的支持。

我在哪里可以找到可以帮助我为 Android 2.1 (Eclair),即 API 7 级生成正确的 .dex 文件的信息? 我甚至不知道 API 级别的 .dex 格式版本字符串是什么!

对于 "bonus points",我真的很想找到一些很好的参考来解释所有 API 级别(至少回到 API 级别 7)之间的 .dex 格式差异。如果 Android API 级别之间的二进制 .xml 和资源文件(由 aapt 工具发出)的格式有任何实质性差异,我也会感兴趣.我认为 .apk 格式本身以及签名算法很有可能完全没有改变 ,因为它与用于签名的格式相同 [=33] =] .jar 文件(即 META-INF/ 子目录中带有一些简单特殊文件的常规 .zip 文件)。但是 .dex 格式规范(包括字节码)可能是最重要的部分,或者至少是一个很好的起点。

https://source.android.com/devices/tech/dalvik/dex-format 简要介绍了版本之间的差异。

Note: Support for version 037 of the format was added in the Android 7.0 
release. Prior to version 037 most versions of Android have used version 035 of 
the format. The only difference between versions 035 and 037 is the addition of 
default methods and the adjustment of the invoke.

Note: Support for version 038 of the format was added in the Android 8.0 
release. Version 038 added new bytecodes (invoke-polymorphic and invoke- 
custom) and data for method handles.

虽然,请注意最新版本是 039,文档中似乎没有提到。 iirc,039 添加了 invoke-custom/rangeconst-method-handleconst-method-type 指令。

其他信息来源包括查看这些文档的更新日志: https://android.googlesource.com/platform/docs/source.android.com/+log/refs/heads/master/en/devices/tech/dalvik/dex-format.html https://android.googlesource.com/platform/docs/source.android.com/+log/refs/heads/master/en/devices/tech/dalvik/dalvik-bytecode.html

在此之前,在移动文件之前:

https://android.googlesource.com/platform/docs/source.android.com/+log/a3b748b40bab557fb47fe5a48a5bfb642837fb05/src/devices/tech/dalvik/dex-format.jd https://android.googlesource.com/platform/docs/source.android.com/+log/a3b748b40bab557fb47fe5a48a5bfb642837fb05/src/devices/tech/dalvik/dalvik-bytecode.jd

此外,您应该能够从 smali 源中收集到一些信息。对于每条指令,它都有 min/max api levels(如果适用)。

对于min/max设置为艺术版的说明,您可以使用this mapping映射回api级别。