Sunday, December 21, 2014

Hello World, meet our new experimental toolchain, Jack and Jill


We've been working on a new toolchain for Android that’s designed to
improve build times and simplify development by reducing dependencies on
other tools. Today, we’re introducing you to Jack (Java Android
Compiler Kit) and Jill (Jack Intermediate Library Linker), the two tools
at the core of the new toolchain.
We are making an early, experimental version of Jack and Jill
available for testing with non-production versions of your apps. This
post describes how the toolchain works, how to configure it, and how to
let us know of your feature requests and any bugs you find.

So how does it work?

When the new tool chain is enabled, Jill will translate any libraries
you are referencing to a new Jack library file (.jack). This prepares
them to be quickly merged with other .jack files. 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. During the process,
Jack also handles any requested code minification. The output is then
assembled into an APK file as normal. We also include support for
multiple dex files, if you have enabled that support.

How do I use it?

Jack and Jill are already available in the 21.1.1+ Build Tools for
Android Studio. Complementary Gradle support is also currently available
in the Android 1.0.0+ Gradle plugin. To get started, all you need to do
is make sure you're using these versions of the tooling and then add a
single line in your build.gradle file. Perform a build of your application to receive a newly built APK.
android {
    ...
    buildToolsRevision '21.1.1'
    defaultConfig {
      // Enable the experimental Jack build tools.
      useJack = true
    }
    ...
}


If you want to build your app with both toolchains,
Product Flavors are a great way to do this. Your build.gradle file might look something like the snippet below.

android {
    ...
    productFlavors {
        dev {
            ...
        }
        experimental {
            useJack = true
        }
        prod {
            ...
        }
    }
    ...
}

How do I configure my build?

We are making the transition to Jack as smooth as possible by
supporting minification (shrinking and/or obfuscation), as well as
repackaging (i.e. similar to tools like jarjar), while using the same
input files as you are used to. Minification is available in the Gradle
plugin immediately and repackaging will follow. You should continue to
use the "minifyEnabled true" directive to reduce the size
of your app among all other optimizations you would normally use. There
are more details on our reference page (linked below) regarding the
level of support for each type of optimization. We encourage you to
provide feedback there if your current configuration isn't supported.

0 comments:

Post a Comment

Thank you very much for your comments ....................... Please stay with this blog