Automatic versioning of Android build using git describe with Gradle

Put the following in your build.gradle file for the project. There’s no need to modify the manifest directly: Google provided the necessary hooks into their configuration. def getVersionCode = { -> try { def code = new ByteArrayOutputStream() exec { commandLine ‘git’, ‘tag’, ‘–list’ standardOutput = code } return code.toString().split(“\n”).size() } catch (ignored) { return … Read more

aar support in Android.mk

You should add following blocks into your Android.mk LOCAL_STATIC_JAVA_AAR_LIBRARIES:= <aar alias> . . . include $(BUILD_PACKAGE) include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := <aar alias>:libs/<lib file>.aar include $(BUILD_MULTI_PREBUILT) Please also be aware of satisfy minSdkVersion required by library into your manifest file.

Disable Manifest Merger in Android Gradle Build

Edit: this is actually possible though indirectly, starting with 0.3 What you need to do is disable the processManifest task so that it doesn’t run and tell the processResources where the manifest to use is: android.applicationVariants.all { variant -> variant.processResources.manifestFile = file(‘src/main/AndroidManifest.xml’) variant.processManifest.enabled=false } Note that if you are customizing the app package name through … Read more

Where does local.properties go for android project?

The local.properties file goes in the project’s root level, in the same folder as the gradlew, gradlew.bat, settings.gradle and other files. This file should not be included in source control. After (incorrectly) including this in source control, then deleting the file locally, Android Studio re-created the file for me automatically. Here is the example content … Read more

Is it possible to declare git repository as dependency in android gradle?

For me the best way is: https://jitpack.io Step 1. Add the JitPack repository to build.gradle at the end of repositories: repositories { // … maven { url “https://jitpack.io” } } Step 2. Add the dependency in the form dependencies { implementation ‘com.github.User:Repo:Tag’ } It is possible to build the latest commit on the master branch, … Read more

How to use the Renderscript Support Library with Gradle

Using Android Studio: Add the following values to build.gradle for android gradle plugin v0.14+ android { … defaultConfig { … renderscriptTargetApi 19 renderscriptSupportModeEnabled true } … } For older versions of the android gradle plugin v0.13.3 and below android { … defaultConfig { … renderscriptTargetApi 19 renderscriptSupportMode true } … } Once that is done, … Read more

How to set different applicationId for each flavor combination using flavorDimensions?

The solution proposed by Fredrik stopped working after upgrading Android Studio to 1.0.2 (and gradle plugin to 1.0.0) so I had to add following changes, current as of gradle plugin 1.3.1: flavorDimensions “price”, “dataset” productFlavors { free { dimension “price” } paid { dimension “price” } dataset1 { dimension “dataset” } dataset2 { dimension “dataset” … Read more