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.
- Mike James is author of Android Programming: Starting With An App, 2nd Ed (I/O Press) ISBN: 978-1871962512, a beginner's guide to using Android Studio, which covers the latest release, Android Studio 2.3.
When it first appeared on the scene, Github was one of a kind and a true visionary amongst its rivals still using Subversion, Bazaar or Mercurial as their source control system.
After an outcry from its existing customers when it announced a new a subscription service for its range of desktop developer tools, JetBrains has now settled on a pricing model that includes a Perpetual Fallback Licence. Is this enough?
- PowerShell Replaces Command Prompt
- Revealing the Who and Why of Node.js Use
- Uber Drivers Gaming the Algorithm
- Competitive Self-Play Trains AI Well
- Microsoft Showcases Key Value Store
- Top 10 From Around The Web: More Angular Resources
- Google Invests $22 Million In A Fork Of Firefox OS
- Microsoft Open Sources PowerShell And It Runs On Linux
- SQL Server Development Edition For Free
- Go 1.7 Goes Faster and in More Directions
- Help Choose Next EE4J Name
- Microsoft's Astoria Android Emulation Might Not Happen
- Algorithms & Data Structures MicroMasters