Meet JACK & JILL , Android’s experimental toolchain

· ☕ 3 min read · ✍️ Nishant
🏷️
  • #tools
  • #android
  • JACK & JILL are part of the new tool chain for android and in the words of Android Developer Blog

    they are designed to improve build times and simplify development by reducing dependencies on other tools

    In case you are curious, JACK stands for Java Android Compiler Kit and JILL stands for Jack Intermediate Library Linker.

    Woa ..woa..wooaaaa ..thats sounds too technical ..lets slow this down, right.

    JACK & JILL were released as an experimental tool chain in the Android SDK 21.1.1 and recently got minor bug fixes in the recent release of Android SDK 21.1.2

    So what exactly are they for ?
    JACK basically compiles your Java code directly to a .dex Dalvik Executable.
    JILL on the other hand translates any libraries you are referencing to a new Jack library file (.jack).

    Whats the difference ?
    Glad you asked :)
    The usual process of android compilation process is

    1. Use the standard javac compiler to convert the source code to Java bytecode
    2. Feed this bytecode to dex compiler to get the Dalvik bytecode

    JACK eliminates the conversion to Java bytecode step and directly converts source code to Dalvik bytecode. During the same time it also handles any requested code minification (shrinking and/or obfuscation), previously handled by Proguard and then perform repackaging too.

    Now all this time, JACK was working on you source code, right!
    What if you have a library being referenced in the form of say a JAR?
    JILL takes care of that, by converting all libraries to Jack Library File (.jack) which can easily be merged by JACK during compilation into object code.
    Basically the Android Gradle plugin and JACK collect any .jack library files, along with your source code, and compiles them into a set of dex files and further assembles them into an APK.

    The complete process explained in a diagram

    jacksitesdiagram

    Why all the hassle for compiler ?
    Google believes in optimizing the whole process of compilation of android apps. The faster that happens the better, maybe involve incremental compilation for the same(still under development)! :D
    Also due to the Oracle-Google dispute over using java , Google probably wants to move away from using javac and have its own compiler in place to convert source code to dalvik bytecode.

    How do you use the tool chain in your apps ?
    Good question! At the moment JACK & JILL are both in experimental phase.
    So you specifically need to enable them in your build.gradle i.e. you need to set useJack = true

    1
    2
    3
    4
    5
    6
    7
    8
    9
    
    android {
        ...
         buildToolsRevision '24.0.1'
         defaultConfig {
             // Enable the experimental Jack build tools.
             useJack = true
             }
        ...
     }
    

    More Info at Android Tools Project Site

    Downside ?
    As of now these support only Java 7 i.e no support for Java 8 :(
    No Annotation processing :(

    Thats it for now.
    Any questions are always welcome :D

    References

    Share on
    Support the author with

    Nishant Srivastava
    WRITTEN BY
    Nishant
    👨‍💻 Android Engineer/🧢 Opensource enthusiast

    What's on this Page