什么是 Android 中的 ODEX 文件? [英] What are ODEX files in Android?
问题描述
安装一些 android
应用程序后,我发现它会在智能手机中更改为 odex
文件(不是 apk
).它是如何发生的?谁能教教我,我很感兴趣.
After some android
apps installed, I found that it will change to odex
file (not apk
) in smartphone.
How does it happens? Who can teach me, I am very interested about it.
推荐答案
博客文章大部分是对的,但不是完全的.要全面了解 odex 文件的作用,您必须先了解一些应用程序文件 (APK) 的工作原理.
The blog article is mostly right, but not complete. To have a full understanding of what an odex file does, you have to understand a little about how application files (APK) work.
应用程序基本上是美化的 ZIP 档案.Java 代码存储在名为 classes.dex 的文件中,该文件由 Dalvik JVM 解析,处理后的 classes.dex 文件的缓存存储在手机的 Dalvik 缓存中.
Applications are basically glorified ZIP archives. The java code is stored in a file called classes.dex and this file is parsed by the Dalvik JVM and a cache of the processed classes.dex file is stored in the phone's Dalvik cache.
odex 基本上是应用程序 classes.dex 的预处理版本,它可以为 Dalvik 执行.对应用程序进行 odexed 后,classes.dex 将从 APK 存档中删除,并且不会向 Dalvik 缓存写入任何内容.一个没有 odexed 的应用程序最终会得到 2 个 classes.dex 文件的副本——一个打包在 APK 中,另一个在 Dalvik 缓存中处理.由于 Dalvik 必须提取和处理 classes.dex 文件,因此第一次启动也需要更长的时间.
An odex is basically a pre-processed version of an application's classes.dex that is execution-ready for Dalvik. When an application is odexed, the classes.dex is removed from the APK archive and it does not write anything to the Dalvik cache. An application that is not odexed ends up with 2 copies of the classes.dex file--the packaged one in the APK, and the processed one in the Dalvik cache. It also takes a little longer to launch the first time since Dalvik has to extract and process the classes.dex file.
如果您正在构建自定义 ROM,那么对您的框架 JAR 文件和库存应用程序进行 odex 处理是一个非常好的主意,以便为用户安装的应用程序最大化内部存储空间.如果你想要主题,那么只需 deodex ->应用您的主题 ->reodex ->发布.
If you are building a custom ROM, it's a really good idea to odex both your framework JAR files and the stock apps in order to maximize the internal storage space for user-installed apps. If you want to theme, then simply deodex -> apply your theme -> reodex -> release.
要实际 deodex,请使用 small 和 baksmali:
To actually deodex, use small and baksmali:
https://github.com/JesusFreke/smali/wiki/DeodexInstructions
这篇关于什么是 Android 中的 ODEX 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!