Why should Android AOT compilation be done only at install time

619 views Asked by At

Can anyone tell me why should AOT compilation be performed only at install time. Why cannot we compile ahead on a desktop and install the application on adnroid device?

1

There are 1 answers

2
CommonsWare On

There are many CPU architectures supported by Android. ARM, x86, and MIPS are the three major families, but there are subsets as well (e.g., ARMv5 vs. ARMv7), and there could be other CPUs supporting Android in the future. The best possible binary code is very dependent upon CPU architecture. Doing all of that at compile time means either:

  • a much larger APK file, containing each possible architecture, or

  • lots of APK files, one per architecture, with resulting headaches for distribution (particularly outside of the Play Store)

By doing the AOT at install time, as ART is apparently doing, we remove those limitations, yet still get optimal code.