Saturday, July 25, 2015

A Complete build.gradle for the Experimental Android Gradle Plugin

Along with the latest release of Android Studio 1.3 rc3, the experimental gradle plugin supports NDK integration in a seamless way. However, the official quick guide does not show every essential detail to write a working build.gradle. The tricks to pay attention to is as follows.
  • compileOptions inclduing the sourceCompatibility and targetCompatibility testInstrumentationRunner 
  • packagingOptions multiple cppFlags and ldLibs 
  • specifying of debug ndk abiFilters 
  • dynamic generation of android.productFlavors 
  • dependencies of 'com.android.support.test:runner:0.3' and 'com.android.support.test:rules:0.3' must be compile 
The build.gradle is attached FYI. It is working but unfortunately, the performance is still unacceptable. Even though the Gradle daemon is enabled, dynamically generating android.productFlavors is very slow and consumes more than 2GB memory (seems like the daemon) on MacBook Pro 2015 with Intel Core i5 2.7GHz and 8GB RAM. The build.gradle is attached FYI where each flavor is generated in term of a given configuration. The Gradle sync takes 3 to 4.5 minutes to complete around 300 flavors (debug+release) whenever there is a small change of the script which is hard to accept. Hopefully, this can be solved by improving the flavor creation process.


No comments:

Post a Comment