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.
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. 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
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.
More InformationNext-generation Dex Compiler Now in Preview Related ArticlesKotlin - 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, Facebook or Linkedin.
Comments
or email your comment to: comments@i-programmer.info
|
Last Updated ( Tuesday, 15 August 2017 ) |