Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Android Pre-Dexing and how to does it increase performance?

Tags:

I see ant script of Android has message that it is "pre-dexing". However dex and pre-dex uses same options, except that in one case one jar at a time, in other case multiple jars at a time.

What is the real need? Is pre-dex mandatory?

e.g

The ' characters around the executable and arguments are not part of the command.       [dex] Pre-Dexing F:\users\tejasoft\work\fnd\cmn\tools\social\sz\demo\libs\pinit-sdk-1.0.jar -> pinit-sdk-1.0-e3bebafa2727504605edf3d8d85b5d46.jar        [dx] Current OS is Windows 7        [dx] Executing 'D:\Apps\java\embd\cmn\android\oems\google\adt\4.x\4.3.x\4.3\sdk\build-tools\18.1.0\dx.bat' with arguments:        [dx] '--dex'        [dx] '--output'        [dx] 'F:\users\tejasoft\work\fnd\cmn\tools\social\sz\demo\bin\dexedLibs\pinit-sdk-1.0-e3bebafa2727504605edf3d8d85b5d46.jar'        [dx] 'F:\users\tejasoft\work\fnd\cmn\tools\social\sz\demo\libs\pinit-sdk-1.0.jar'        [dx]         [dx] The ' characters around the executable and arguments are        [dx] not part of the command. Execute:Java13CommandLauncher: Executing 'D:\Apps\java\embd\cmn\android\oems\google\adt\4.x\4.3.x\4.3\sdk\build-tools\18.1.0\dx.bat' with arguments: '--dex' '--output' 'F:\users\tejasoft\work\fnd\cmn\tools\social\sz\demo\bin\dexedLibs\pinit-sdk-1.0-e3bebafa2727504605edf3d8d85b5d46.jar' 'F:\users\tejasoft\work\fnd\cmn\tools\social\sz\demo\libs\pinit-sdk-1.0.jar'  The ' characters around the executable and arguments are not part of the command.       [dex] Converting compiled files and external libraries into F:\users\tejasoft\work\fnd\cmn\tools\social\sz\demo\bin\classes.dex...        [dx] Current OS is Windows 7        [dx] Executing 'D:\Apps\java\embd\cmn\android\oems\google\adt\4.x\4.3.x\4.3\sdk\build-tools\18.1.0\dx.bat' with arguments:        [dx] '--dex'        [dx] '--output'        [dx] 'F:\users\tejasoft\work\fnd\cmn\tools\social\sz\demo\bin\classes.dex'        [dx] 'F:\users\tejasoft\work\fnd\cmn\tools\social\sz\demo\bin\classes'        [dx] 'F:\users\tejasoft\work\fnd\cmn\tools\social\sz\demo\bin\dexedLibs\classes-144740ee5cf8b90b747300d19fb8201e.jar'        [dx] 'F:\users\tejasoft\work\fnd\cmn\tools\social\sz\demo\bin\dexedLibs\classes-1593da1bb60c5ec741aca494963e04a3.jar'        [dx] 'F:\users\tejasoft\work\fnd\cmn\tools\social\sz\demo\bin\dexedLibs\classes-37bb5269e4fbd6dda9900fea95c0c29b.jar' 
like image 750
Raja Nagendra Kumar Avatar asked Oct 07 '13 14:10

Raja Nagendra Kumar


People also ask

What is Android dexing?

Dexing is the process of converting standard Java JVM byte code (in the form of a . jar archive file created by the compiler) into Android's native format, Dalvik or ART. This is done by a tool called dex or its more modern replacement d8 , which is part of the standard Android build tools.

What is performance in Android programming?

A performance class defines a set of device capabilities that goes beyond Android's baseline requirements. Each version of Android has its own corresponding performance class, which is defined in that version's Android Compatibility Definition Document (CDD).

Why does Android studio take so long?

According to Android Studio's official system requirements, it takes at minimum 3 GB RAM to run smoothly. Honestly, its a lot and I believe that is the biggest cause of being it too slow all the time.


1 Answers

It's useful to remember in this case that you are working in Java, which is not exactly the same thing as the Dalvik runtime. Java, from Oracle, uses a completely different virtual machine, while Dalvik is specifically fine-tuned for mobile devices.

The DEX processes take your Java compiled JAR files and converts them into Dalvik Executable Files (.dex) files that will run on Android. The Oracle JVM uses different bytecode than the Dalvik runtime, making this step a necessity.

There is a process for libraries you might have included in your project, as they are also compiled with a standard Java compiler, and then another process for your actual project.

It's done in two steps as the final process, your application, requires access to already dexed library files to avoid having references to code change while the process is busy.

You can find out more at http://source.android.com/devices/tech/dalvik/index.html - where you will also see that Dalvik is scheduled for replacement with something called ART.

like image 83
Ewald Avatar answered Sep 23 '22 01:09

Ewald