Technical docs‎ > ‎

    New Build System

    We are working on a new build system to replace both the build system inside ADT and Ant.

    Google I/O 2013: The New Android SDK Build System

    Samples are at the bottom of this page.

    Release notes:

    0.13.0 (2014/09/18)
    • Requires Gradle 2.1
    • It is now possible to provide a manifest for test apps (src/androidTest/AndroidManifest.xml)
    • AndroidManifest files in Library project can now include placeholders. If they cannot be resolved in the libraries, they'll be resolved in the consuming project.
    • AndroidManifest placeholder can now be setup on Product Flavors and Build Types.
    • Variant.getMappingFile() API now allow querying for the proguard mapping file.
    • New Split mechanism for Density and ABI driven multi-apk. Documentation here.
    • Bug fixes:
      • Fix issue where consumer proguard file (from aars) are ignored on first build
      • Fixed aar output names so that variants do not overwrite each other
      • Properly merge declare-styleable to contain all attrs.
      • Fix whitespace issue in resource strings during resource merge.

    0.12.2 (2014/07/16)
    • Fix packaging of wear application
    • Fix issue with ${applicationId} placeholder when build.gradle doesn't customize it.
    • Custom Java code generation steps now part of the source generation steps (fix IDE integration).
    • Move unzipped aar back in each project as a temporary fix for a possible race condition.
    0.12.1 (2014/07/01)
    • Fix merging of the package attribute in the manifest.
    0.12.0 (2014/06/25)
    • New IDE Model, requires Studio Beta 0.8
    • Fixes in the manifest mergers.
    0.11.1
    • Fix issue with artifact depending on android.jar artifact on MavenCentral.
    • Fix issue with missing custom namespace declaration in generated manifest.
    • Fix issue with validation of permission group in manifest merger.

    0.11.0
    • Updated IDE model, requires Studio 0.6
    • Supports Gradle 1.10, 1.11, 1.12.
    • New Manifest merger is now the default merger.
      • lots of fixes.
      • Added ability to add custom placeholders for manifest on flavor objects
        defaultConfig {
            manifestPlaceholders = [ activityName:"defaultName"]
        }
    • Moved files and folders around in the buildDir for better IDE integration.
    • Generated APK can now be published. Same configuration as libraries with defaultPublishConfig and publishNonDefault flags.
    • Breaking API/DSL Changes:
      • ProductFlavor.packageName is now applicationId. Setters for packageName are still temporarily present but will disappear in 1.0
      • ProductFlavor.testPackageName is now testApplicationId. Setters for testPackageName are still temporarily present but will disappear in 1.0
      • minSdkVersion/targetSdkVersion on ProductFlavor is now a ApiVersion instance instead of an integer.
        • DSL impact
          • Cannot use setter in DSL, use method instead. Basically, do not use '='
            flavor {minSdkVersion = 9 }
            replaced with :
            flavor { minSdkVersion 9 }
          • This is due to a groovy limitation preventing overloaded setters.
        • interface ApiVersion {
              int getApiLevel();
              int getCodename();
          }

    0.10.4
    • Fix manifest merger bugs (including proper location of the application node in the generated manifest)
    • Fix issues where flavors in library with different packages would not generate the right R class.
    • Fix issue when parsing BOM in UTF8 encoded XML files.
    • Lint fixes
    0.10.3
    • No release due to a problem during the push.
    0.10.2
    • More fixes on the Manifest merger, including better handling of minSdkVersion.
    • More lint fixes.
    • Fixed incremental dex support (still needs to be enabled)
    0.10.1
    • fixed some issues with the new manifest merger. Please keep sending us feedback.
    • fixed issue with uninstall task.
    • lots of lint fixes and new checks. For instance you can use lint to enforce resource prefix in your library.
    0.10.0
    • Supports Gradle 1.10, 1.11, 1.12.
      • Gradle 1.12 will require Studio 0.5.8
    • New manifest merger.
      • Disabled by default. Enable with android.useOldManifestMerger = false
      • See documentation here.
    • Test code coverage support with Jacoco
      • Enable in the tested Build Type with testCoverageEnabled = true
      • HTML and XML Report generated in build/reports/coverage
      • Configure version of Jacoco with
        android {
          jacoco {
            version = '0.6.2.201302030002'
          }
        }
      • Known issue: This is not compatible with using Dagger.
    • Resource Prefix support.
      • Setup the prefix in your library with
        android {
          resourcePrefix 'mylib_'
        }
      • Starting with Studio 0.5.8 Lint will warn you or resources not using the prefix. (Work in Progress)
    • Pre-dex cache (in rootProject/build). Shared across modules and variants. Should speed up builds.
    • Exploded aar are extracted in a single location (under rootProject/build) to share across all modules using it. May speed up builds.
    • Upgraded to Proguard 4.11. Fixed incremental issues.
    • Fixed incremental issues with aidl files.
    • variant API to access the proguard task is now under the generic name "obfuscation".
    0.9.2
    • Aapt-based PNG processor is now default again while we investigate some issues with the old one.
    • flavorGroups have been renamed flavorDimensions and the DSL has been updated. The old DSL is still available until 1.0 at which time it'll be removed.

    0.9.1
    • It's now possible to include a file when there's a conflict during packaging:
          android.packagingOptions {
              pickFirst 'META-INF/foo.txt'
          }

    • New PNG processor.
      • Should be much faster when processing many files
      • Fix issue where crunched png are bigger than original file
      • To revert to the old cruncher: android.aaptOptions.useAaptPngCruncher = true
        WARNING: We've seen reports of the new processor generating PNGs that make the app crash on GB
    • The plugin now enforces that all library dependencies have a unique package name.
      • To disable this you can use android.enforceUniquePackageName = false
      • WARNING: The ability to disable enforcement will disappear in 1.0
    • Fixes:
      • Generated POM files now have the proper dependencies even if the pom object is manipulated in build.gradle
      • libraryVariant API now gives access to the list of flavors.
      • fixed issue where changes to the manifests of libraries didn't trigger a new manifest merge.
      • BuildConfig.VERSION_NAME is always generated even if the value is not set in the current variant.
      • BuildConfig is now packaged in libraries. This requires that all your libraries have a unique package name.
        • If you are disabling enforcement of package name, then you should disable packaging of BuildConfig with: android.packageBuildConfig = false
        • WARNING: the ability to disable packaging will disappear in 1.0
    0.9.0
    • Compatible with Gradle 1.10 and 1.11
      • Using Gradle 1.11 requires Android Studio 0.5.0
    • BREAKING CHANGES:
      • DSL for Library Projects is now the same as for application projects.
        • You can create/configure more build types, in the buildTypes { ... } container.
        • You can create product flavors using the productFlavors { ... } container.
        • You can create signingConfigs using the signingConfigs { ... } container.
      • instrumentTest was renamed androidTest
        • This is more inline with what the tests are: all type of tests that are run on Android (unit test, instrumentation test, and later uiautomator)
        • Both the default folder names and the android.sourcesets object have been renamed.
        • To migrate you can either rename the folders or point the sourcesets to the old location(s).
      • Dependency configurations for Library Projects are now provided, compile, and publish.
    • Library Publication
      • Variants of libraries can now be published, though by default only the default variant is published. This is a work in progress.
      • TL;DR: this will NOT fix bug 52962, where release variant of the libraries are always used.
      • It does allow you to manually depend on a specific variant of a library. See documentation.
      • change the default with android.defaultPublishConfig
      • enable publication of other variants with android.publishNonDefault = true
      • Reference specific variant with compile project(path: ':project', configuration: 'flavor1Debug')
      • See documentation.
    • Ability to skip some variants. This allows you to not create all possible combinations of build types/flavors.
      • DSL is: android.variantFilter { variant -> ... }
      • The object passed to the closure implements the following methods:
        • public void setIgnore(boolean ignore);
        • @NonNull public ProductFlavor getDefaultConfig();
        • @NonNull public BuildType getBuildType();
        • @NonNull public List<ProductFlavor> getFlavors();
      • To skip a variant, call setIgnore(true).
      • This cannot be used in afterEvaluate.
    • The publish and apk configurations don't extend compile anymore but the composite internal configurations are still properly setup (this should not break anything).
    • Fix issue where variant specific source folders where not used for java compilation.
    • Fix for some Renderscript support mode compatibility issues. Requires Build Tools 19.0.3
    • Lots of misc fixes.
    0.8.3
    • Fix Studio integration
    0.8.2
    • Fix incremental compilation issue with BuildConfig fields and generated Res values.
    0.8.1
    • Added the ability to create resource values through the DSL.
    • You can now use resValue <type>,<name>,<value> on build types and product flavors the same way you can use buildConfigField.
    • Fixed package renaming in activity-alias:targetActivity
    • Variant API improvements:
      • packageName returns the variant's package name
      • versionCode returns the (app/test) variant's versionCode
      • versionName returns the (app/test/) variant's versionName. Can return null.
    • Misc fixes
    0.8.0
    • Requires Gradle 1.10
    • Requires Build-Tools 19.0.0+
    • Fixed issue 64302: Add renderscript support mode jar to the dependencies in the IDE model.
    • Fixed issue 64094: buildConfigField can now replace previous values inside the same type/flavors.
    • Add support for NDK prebuilts in library projects.
    • Parallelize pre-dexing to speed up clean builds.
    • Incremental dexing re-enabled (though it'll be automatically disabled in some builds for some cases that dx doesn't support yet.)
    • Added 'provided' dependency scope for compile only (not packaged) dependencies.
      Additional scope per buildtype and flavors are also available (debugProvided, myFlavorProvided,etc...)
    • Lint improvements:
      • New "lintVital" task, run automatically as part of assembling release variants, which checks only fatal-severity issues
      • Replace Java parser in lint with ECJ; must faster and fixes bug where lint could hang on certain source constructs
      • Lint HTML report now writes links to source files and images as URLs relative to the report location
    • Variant API improvements:
      • getPreBuild() returns the prebuild task for the variant
      • getSourceSets() returns the sorted sourcesets for the task, from lower to higher priority
      • createZipAlignTask(String taskName, File inputFile, File outputFile)
        This creates and return a new zipalign task. Useful if you have a custom plugin providing custom signing of APKs.
        This also makes the assemble task depend on the new zipalign task, and wires variant.getOutputFile() to return the result of the zipalign task.
      • project.android.registerJavaArtifact() now receives a Configuration object to pass the dependencies to the IDE. See artifactApi sample.
    0.7.3
    • Re-enable Java6 support
    0.7.2

    Note: 0.7.2 requires Java7. This is a mistake. Use 0.7.3 instead.
    • Fix issue with Proguard.
    • Add packagingOptions support in Library projects.
    • Solve issue with local jar when testing library projects.
    • Fix bug with variant.addJavaSourceFoldersToModel
    • Add jniLibs folder to source sets for prebuilt .so files.
    • Lint fixes:
      • fix RTL detector
      • fix HTML report to have valid HTML
    New Samples: ndkJniLib, genFolderApi2

    0.7.1
    • DSL to ignore duplicate files
      android {
        packagingOptions {
          exclude 'META-INF/LICENSE.txt'
        }
      }

    • Fix in the lint task to trigger compilation of the variants

    0.7.0
    • Requires Gradle 1.9
    • Requires Studio 0.4.0
    • You can now have a variant specific source folder if you have flavors.
      • Only for app (not library or test). Name is src/flavorDebug/... or src/flavor1Flavor2Debug/
        • Note the camelcase naming, with lower case for first letter.
      • Its components (res, manifest, etc...) have higher priority than components from build type or flavors.
      • There is also a "flavor combination" source folder available when more than one flavor dimension is used. For instance src/flavor1Flavor2/
        • Note that this is for all combinations of *all* dimensions.
        • Its priority is higher than single-flavor sourcesets, but lower than build-types.
    • Lint improvements
      • Revamped lint integration. Lint is now run as part of the check task, and will analyze all variants and then merge the results and create a report which lists which variants each error applies to (unless an error applies to all variants). You can also run lint on a specific variant, e.g. lintDebug or lintFreeRelease.
      • Lint will no longer report errors in AAR libraries. This version of the plugin also picks up some new lint checks.
      • A new DSL allows configuration of lint from build.gradle. This is read and used in Studio
      • See 'basic' sample.
    • Build config improvements and DSL changes.
      • buildConfigLine is replaced by buildConfigField
      • Only one field per property
      • expects 3 values, type, name, value.
      • This allows overriding a value in flavor or build type.
      • See "basic" sample.
    • Build Config now automatically contain more constants for PACKAGE_NAME, VERSION_CODE, VERSION_NAME, BUILD_TYPE, FLAVOR as well as FLAVOR_<group> if there are several flavor dimensions.
    • Switch to ProGuard 4.10
    • Added ability to test proguarded (obfuscated) apps.
    • New option on product Flavor (and defaultConfig) allow filtering of resources through the -c option of aapt
      • You can pass single value (resConfig) or multiple values (resConfigs) through the DSL.
      • All values from the default config and flavors get combined and passed to aapt.
      • See "basic" sample.
    • Jar files are now pre-dexed for faster dexing.
    • Incremental dexing is currently disabled, as we have uncovered some issues.
    • Renderscript support mode.
      • See sample 'rsSupportMode'
    • New test-related DSL properties on defaultConfig and flavors:
      • testHandleProfiling: boolean, fills in the handleProfiling attribute on the instrumentation node in the manifest.
      • testFunctionalTest: boolean, fills in the functionalTest attribute on the instrumentation node in the manifest.
    • API to add new generated source folders:
      • Adding a source folder for the model (for IDE support):
        • variant.addJavaSourceFoldersToModel(sourceFolder1, sourceFolders2,...)
      • Automatically adding dependency on the task, setting up the JavaCompile task inputs and propagating folder to the model:
        • variant.registerJavaGeneratingTask(task, sourceFolder1, sourceFolders2,...)
      • See sample 'genFolderApi'
    • API to add extra artifacts on variants. This will let you register Java or Android artifacts, for instance for alternative test artifacts.
      • See sample 'artifactApi' for the API (sample is not meant to be used, it's for testing).
    • Fixed issue with parentActivityName when handling different package name in the manifest merger.
    • Allow files inside folder META-INF/ from jars to be packaged in the APK.

    0.6.3
    • Fixed ClassNotFoundException:MergingException introduced in 0.6.2
    0.6.2
    • Lint now picks up the SDK home from sdk.dir in local.properties
    • Error message shown when using an unsupported version of Gradle now explains how to update the Gradle wrapper
    • Merged resource files no longer place their source markers into the R file as comments
    • Project path can contain '--' (two dashes)
    • Internal changes to improve integration with Android Studio
    0.6.1
    • Fixed issue with "lint" task when executing task "check"
    0.6.0
    • Gradle 1.8 is now the minimum supported version
    • Default encoding for compiling Java code is UTF-8
    • Users can now specify the encoding to use to compile Java code
    • Fixed Gradle 1.8-specific bugs
      •   Importing projects with missing dependencies was broken
      •   Compiling projects with AIDL files was broken
    Setting the encoding to use for compiling Java code is as simple as:
    android {
        compileOptions.encoding = "UTF-8"
    }

    0.5.7
    • Proguard support for libraries. Note the current DSL property 'proguardFiles' for library now sets the proguard rule file used when proguarding the library code. The new property 'consumerProguardFiles' is used to package a rule file inside an aar.
    • Improved IDE support, including loading project with broken dependencies and anchor task to generate Java code
    • New hook tasks: preBuild and prebuild<VariantName>
    • First lint integration. This is a work in progress and therefore the lint task is not added to the check task.
    • Enable compatibility with 1.8 (though note that we later released 0.6.0 to handle additional 1.8 issues discovered after 0.5.7 was released.)
    0.5.6
    • Enable support for Gradle 1.7
    0.5.5
    • Fix issue preventing to use Build Tools 18.0.1
    • access to the variants container don't force creating the task.
      This means android.[application|Library|Test]Variants will be empty during the evaluation phase. To use it, use .all instead of .each
    • Only package a library's own resources in its aar.
    • Fix incremental issues in the resource merger.
    • Misc bug fixes.
    0.5.4
    • Fixed incremental compilation issue with declare-styleable
    0.5.3
    • Fix a crashing bug in PrepareDependenciesTask
    0.5.2
    • Better error reporting for cmd line tools, especially if run in parallel in spawned threads
    • Fix an issue due to windows path in merged resource files.
    0.5.1
    • Fix issue in the dependency checker.
    What's new in 0.5.0
    • IDE Model is changed and is not compatible with earlier version! Version 0.2.0+ of Studio is required.
    • Fixed IDE model to contain the output file even if it's customized through the DSL. Also fixed the DSL to get/set the output file on the variant object so that it's not necessary to use variant.packageApplication or variant.zipAlign
    • Fixed dependency resolution so that we resolved the combination of (default config, build types, flavor(s)) together instead of separately.
    • Fixed dependency for tests of library project to properly include all the dependencies of the library itself.
    • Fixed case where two dependencies have the same leaf name.
    • Fixed issue where Proguard rules file cannot be applied on flavors.
    0.4.3
    • enable crunching for all png files, not just .9.png
    • fix dealing with non resource files in res/ and assets/
    • fix crash when doing incremental aidl compilation due to broken method name (ah the joy of Groovy...)
    • clean older R classes when the app package name has changed.
    0.4.2
    • Fixed incremental support for resource merging.
    • Fixed issue where all pngs would be processed in parallel with no limit on the number of thread used, leading to failure to run aapt.
    • Fixed ignoreAsset support in aaptOptions
    • Added more logging on failure to merge manifests.
    • Added flavor names to the TestServer API.

    0.4.1
    • Fixes
      • Renamed 'package' scope to 'apk'
        • variants are 'debugApk', 'releaseApk', 'flavor1Apk', etc...
        • Now properly supported at build to allow package-only dependencies.
        • Only Jar dependencies can be package-only. Library projects must be added to the compile scope.
      • Fixed [application|library|test]Variants API (always returned empty on 0.4)
      • Fixed issue in Proguard where it would complain about duplicate Manifests.
    0.4
    • System requirements
      • Gradle 1.6
      • Android SDK with the Build Tools component version 17.0.0 or above
    • New Features
      • API for 3rd party Device Providers and Test Servers to run and deploy tests. API is @Beta
      • Support for ProGuard 4.9
        • enable with BuildType.runProguard
        • add proguard config files with BuiltType.proguardFile or ProductFlavor.proguardFile
        • default proguard files accessible through android.getDefaultProguardFile(name) with name being 'proguard-android.txt' or 'proguard-android-optimize.txt'
      • Implemented Gradle 1.6 custom model for IDE Tooling support
    • Fixes and other changes
      • Renamed deviceCheck into connectedCheck
      • Fixed support for subfolders in assets/
      • Fixed cases where Android Libraries have local Jars dependencies
      • Fixed renaming of package through DSL to ensure resources are compiled in the new namespace
      • Fixed DSL to add getSourceSets on the "android" extension.

    0.3
    • System requirements:
      • Gradle 1.3+ (tested on 1.3/1.4). Will not be compatible with 1.5. An update will be required.
      • Android Platform Tools 16.0.2+
    • New Features:
      • Renderscript support.
      • Support for multi resource folders. See 'multires' sample.
        • PNG crunch is now done incrementally and in parallel.
      • Support for multi asset folders.
      • Support for asset folders in Library Projects.
      • Support for versionName suffix provided by the BuildType.
    • Testing
      • Default sourceset for tests now src/instrumentTest (instrumentTest<Name> for flavors)
      • Instrumentation tests now:
        • started from "deviceCheck" instead of "check"
        • run on all connected devices in parallel.
        • break the build if any test fails.
        • generate an HTML report for each flavor/project, but also aggregated.
      • New plugin 'android-reporting' to aggregate android test results across projects. See 'flavorlib' sample.
    • Improved DSL:
      • replaced android.target with android.compileSdkVersion to make it less confusing with targetSdkVersion
      • signing information now a SigningConfig object reusable across BuildType and ProductFlavor
      • ability to relocate a full sourceSet. See 'migrated' sample.
      • API to manipulate Build Variants.
    • Fixes:
      • Default Java compile target set to 1.6.
      • Fix generation of R classes in case libraries share same package name as the app project.
      0.2
      • Fixed support for windows.
      • Added support for customized sourceset. (http://tools.android.com/tech-docs/new-build-system/using-the-new-build-system#TOC-Working-with-and-Customizing-SourceSets)
      • Added support for dependency per configuration.
      • Fixed support for dependency on local jar files.
      • New samples "migrated" and "flavorlib"


      Current limitations of version 0.9.x
      • NDK Integration is very basic, limited and not documented. See samples
      • No code coverage support
      • Manifest merger is very limited.
      • Library projects only expose their release variants.
      You can download a small bundle containing a few different (mostly empty) projects that show some of the build features: here

      Older docs, needs updating.

      What can you do?

      Send feedback, lots of it. And bug reports. Thanks!

      Contributing

      This is developed entirely in AOSP. Go to source.android.com to see how to get the source code.

      For instructions on how to build, debug and test the Gradle plugin, see Building the Android Gradle Plugin.

      Contribute patches through the standard AOSP workflow, and talk to use on adt-dev.
      Č
      ċ
      gpsdemos.zip
      (1785k)
      Xavier Ducrohet,
      May 30, 2013, 12:23 PM
      ċ
      Xavier Ducrohet,
      Apr 30, 2014, 9:52 AM
      ċ
      Xavier Ducrohet,
      Jun 6, 2014, 4:42 PM
      ċ
      Xavier Ducrohet,
      Sep 18, 2014, 10:20 AM
      ċ
      Xavier Ducrohet,
      Jul 12, 2013, 11:19 AM
      ċ
      Xavier Ducrohet,
      Dec 26, 2013, 9:22 PM
      ċ
      Xavier Ducrohet,
      Jan 23, 2014, 10:32 AM
      ċ
      Xavier Ducrohet,
      Mar 5, 2014, 10:26 AM