into the Android Development Kit • Eclipse is the IDE and Ant the command-line/automated build tool. • Google I/O April 2013 Xavier Ducrohet Announced deprecating Eclipse and Ant in favor of IntellaJ and Gradle http://www.youtube.com/watch?v=LCJAgPkpmR0 http://tools.android.com/tech-docs/new-build-system/ user-guide
Plugins, Domain Specific Language (DSL) • APIs and IDE Integration • Free/ Open Source • Convention over configuration • Maven and Ant Integration • Based on Groovy http://www.gradle.org
} dependencies { classpath 'com.android.tools.build:gradle:0.6.+' } } apply plugin: 'android' • buildscript - this is the configuration for Gradle at build time. • repositories - repositories where the Gradle plugins are found • dependencies - plugins etc. for Gradle - not available for the compiler, but for the thing that runs the compiler • apply plugin - use the android plugin found in the dependency artifact
include: '*.jar') compile project(':YambaClientLib') compile project(':YambaContract') } • dependencies - this module’s dependencies. Can be other modules (projects) .jar files or maven artifacts. • compile fileTree - include all the jar files in the libs directory (just like and and eclipse) • compile project - use the Android Library listed. Similar to the “is library” checkbox on the Android config page in ADT and using android update lib-project in Ant.
“17.0.0" … } • android - configure the parameters for the android build. No need for the java plugin. • compileSdkVersion - required. Similar to the —target option in the old android update project tool or selecting the target in the Eclipse IDE. Can be an int or string (i.e. 15 or “Google Inc.:Google APIs:15”) • buildToolsVersion - Specify the version of the android built tools. This use the android command or toolbar button in Android Studio to bring up the SDK manager.
main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] aidl.srcDirs = ['src'] renderscript.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } ! instrumentTest.setRoot('tests') } ! } • android - Continued • sourceSets - configure the project structure when you want something different than the default • main - primary source tree - default “flavor”, more on next slide • instrumentTest.setRoot - traditional android unit tests.
new task svnInfo • use groovy fu to call your VCS and redirect stdout to a byte stream that you will convert to a string • take the stdout string and use regex to extract the rev or other • return using the ext capability task svnInfo { new ByteArrayOutputStream().withStream { os -> def result = exec { executable = 'svn' args = ['info'] standardOutput = os } def outputAsString = os.toString() def matchRev = outputAsString =~ /Revision: (\d+)/ ext.rev = matchRev[0][1] println "Latest Changed Revision #: ${ext.rev}" } }
task copyNdkSrc(type:Copy) { // copy so that the libs and obj directory // will be built in the build directory description "copy from src/main/jni to $buildDir/jni" from "src/main/jni" into "$buildDir/jni" include '**/*' } ! task ndkBuild(dependsOn: ['copyNdkSrc'], type:Exec) { description "Build the Native JNI library" outputs.dir "$buildDir/obj" inputs.dir "$buildDir/jni" environment NDK_PROJECT_PATH:'build' commandLine "${System.env.NDK_HOME}/ndk-build" args 'V=1' } Copy the source before building, otherwise it will pollute the src directory.
the Android build later file("$buildDir/libs").renameTo("$buildDir/ndk-libs") } ! task nativeLibsToJar(type: Zip, dependsOn: ndkBuild) { description 'create a jar archive of the native libs' buildDir.mkdir() destinationDir new File(file(buildDir), "native-libs") baseName 'native-libs' extension 'jar' from fileTree(dir: "$buildDir/ndk-libs", include: '**/*.so') into 'lib/' } Move the native libs out of the generic libs directory.
from your graphic artist • Integrate updates more quickly • Automatically generate icons based on each pixel density bin • res/drawable-hdpi • res/drawable-mdpi • res/drawable-xhdpi • res/drawable-xxhdpi • Not Android Specific
Android Plugin docs http://tools.android.com/ tech-docs/new-build-system/user-guide • Yamba demo app originated by Marco Gargenta and the Marakana/New Circle Team https://github.com/ twitter-university/yamba • Gradle http://gradle.org