Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
245 views
in Technique[技术] by (71.8m points)

android - What is dex in Gradle

What is the dex in Gradle or in Android?

In Gradle, what's the meaning of dexoptions?

Sometimes my project does not compile because of some dexerrors. I need to activate ProGuard to compile my Android app.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

In the Android world:

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.

To be clear: a dex file in android is the equivalent of class in standard java.

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 :

  • targetAPILevel
  • force-jumbo mode (when enabled it allows a larger number of strings in the dex files)

To enable jumboMode :

android {
    dexOptions {
        jumboMode = true
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...