Android's Dex Compiler Gets Better
Android's Dex Compiler Gets Better
Written by Mike James   
Tuesday, 15 August 2017

Android did a remarkable about face, the sort that would have made headlines for other project, but they managed to carry it off without anyone really noticing. Basically after planning to build its own compiler Google went back to the old Dex technology and now it is busy improving it. The latest Dex D8 is in the recent Android Studio 3.0 beta. 

 

androiddev

Android uses a very round about way to get an app to run. First the Java, or these days Kotlin, is compiled to standard Java byte code using the standard Java or Kotlin compilers. Next the Dex compiler converts the byte code to Dalvik to run either on the Dalvik VM or ART. The amusing thing is that ART compiles the Dalvik byte code to machine code so that is a very long chain of compilers to get from your source code to something that works. 

The original plan was do drop Dex because changes in moving to Java 8 would require a lot of work. The idea was to implement a one-step compiler, Jack, from Java to Dex. However this idea was dropped and Dex is back in the picture. It has now been upgraded to support Java 8 features and it also supports code generated by Kotlin. Of course, the Jack compiler was a Java-only compiler, so no Kontlin support down that now-abandoned road.

At first everything seemed a bit of a rush to get Dex ready for its new role and the whole thing led to the upgrading of a decimal point upgrade of Android Studio to version 3, which is currently in beta.

I have to say that personally I think that the whole Android project currently lacks focus and Android Studio is currently an over-ambitious mess, but I keep hoping that things will get better as we move from the beta to the final version and that after version 3 things might slow down and we can have some consolidation.

 

 

It does look as if Dex is settling down because the team working on it have time to concentrate on optimization. The latest Dex compiler, D8, which is in the latest Android Studio 3 beta, is faster and produces more compact code.

dex1

Cutting five seconds off a 16-second compile time is good.File sizes have reduced from around 50MByte to 48MBytes which isn't so impressive, but in the right direction. In a very honest sounding statement in the Developer blog we are told:

We have tested D8's correctness and performance on a number of apps, and the results are encouraging. We're confident enough with the results that we are switching to use D8 as the default dex compiler for building AOSP.

I guess if it is good enough for AOSP, it is good enough for the rest of us, but "a number of apps" doesn't sound quite as rigorous as you could hope for.

You can try it by setting

android.enableD8=true

in the gradle properties file.

Dex getting faster is good news because. despite the improvements to instant run. nothing much is instant in Android development.

 astudio

 

More Information

Next-generation Dex Compiler Now in Preview

Related Articles

Android Studio 3

Kotlin - New Language For Android

Android Studio Moves Toward Java 8

Google's Jack & Jill Android Java Compiler Project Is Dead

The New Android Compilers - Meet Jack And Jill 

Android Studio 2.3 - In Need Of Direction

Android Studio 2.2 Preview Big Changes! 

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on, Twitter, FacebookGoogle+ or Linkedin.

 

Banner


Apple And GE Bring Predix to iPad and iPhone
19/10/2017

Apple and GE are making Predix available for iPad and iPhone via a new SDK for iOS, meaning developers have the tools to create Industrial Internet of Things apps on the Apple platform.



The Search For Small Chaotic Circuits
21/10/2017

Chaos and complexity seem to go together, but can you make a chaotic circuit with just small number of parts? A supercomputer search suggests that yes you can and chaos is more common than you might e [ ... ]


More News

 
 

 

blog comments powered by Disqus

 

Last Updated ( Tuesday, 15 August 2017 )
 
 

   
RSS feed of news items only
I Programmer News
Copyright © 2017 i-programmer.info. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.