問題描述
Gradle 或 Android 中的 dex 是什么?
What is the dex in Gradle or in Android?
在Gradle中,dexoptions
是什么意思?
In Gradle, what's the meaning of dexoptions
?
有時我的項目由于某些 dexerrors 而無法編譯.我需要激活 ProGuard 來編譯我的 Android 應用程序.
Sometimes my project does not compile because of some dexerrors. I need to activate ProGuard to compile my Android app.
推薦答案
在標準的java世界中:
當您編譯標準 java 代碼時:編譯器生成 *.class 文件.*class 文件包含可以在標準 JVM 上執行的標準 java 字節碼.
In the standard java world:
When you compile standard java code : the compiler produce *.class file. A *class file contains standard java bytecode that can be executed on a standard JVM.
這是不同的.您使用 java 語言編寫代碼,但編譯器不生成 *.class 文件,它生成 *.dex 文件.*.dex
文件包含可以在 Android 虛擬機 (dalvik) 上執行的字節碼,這不是標準的 Java 虛擬機.
It is different. You use the java language to write your code, but the compiler don't produce *.class files, it produce *.dex file. A *.dex
file contains bytecode that can be executed on the Android Virtual Machine (dalvik) and this is not a standard Java Virtual Machine.
明確一點:android 中的 dex 文件相當于標準 java 中的 class.
To be clear: a dex file in android is the equivalent of class in standard java.
所以 dexoptions
是一個 gradle 對象,其中定義了一些配置此 java-code-to-android-bytecode 轉換的選項.通過這個對象配置的選項是:
So dexoptions
is a gradle object where some options to configure this java-code-to-android-bytecode transformation are defined. The options configured via this object are :
- 目標API級別
- force-jumbo 模式(啟用后允許 dex 文件中包含更多字符串)
啟用 jumboMode
:
android {
dexOptions {
jumboMode = true
}
}
這篇關于Gradle 中的 dex 是什么的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!