Resources & Feedback

Open Source

Social Media

Transform API

Starting with 1.5.0-beta1, the Gradle plugin includes a Transform API allowing 3rd party plugins to manipulate compiled class files before they are converted to dex files.

(The API existed in 1.4.0-beta2 but it's been completely revamped in 1.5.0-beta1)

The goal of this API is to simplify injecting custom class manipulations without having to deal with tasks, and to offer more flexibility on what is manipulated. The internal code processing (jacoco, progard, multi-dex) have all moved to this new mechanism already in 1.5.0-beta1.

Note: this applies only to the javac/dx code path. Jack does not use this API at the moment.

To insert a transform into a build, you simply create a new class implementing one of the Transform interfaces, and register it with android.registerTransform(theTransform) or android.registerTransform(theTransform, dependencies).

Important notes:

The Dex class is gone. You cannot access it anymore through the variant API (the getter is still there for now but will throw an exception)

Transform can only be registered globally which applies them to all the variants. We'll improve this shortly.

There's no way to control ordering of the transforms.

We're looking for feedback on the API. Please file bugs or email us on our adt-dev mailing list.