SlideShare a Scribd company logo
1 of 47
Download to read offline
Level Up Your Android Build - droidcon Berlin 2015
LEVEL UP YOUR ANDROID BUILD
Volker Leck
Friedger Müffke
Droidcon Berlin 2015
Level Up Your Android Build - droidcon Berlin 2015
image
Level Up Your Android Build - droidcon Berlin 2015
image
Phoogle Gotos
Level Up Your Android Build - droidcon Berlin 2015
app/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.2.0"
defaultConfig {
...
}
buildTypes {
release {
...
}
}
}
dependencies {
...
}
Level Up Your Android Build - droidcon Berlin 2015
Relevant Build Files
├── app
│ └── build.gradle
├── build.gradle
├── gradle
│ └── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradle.properties
├── gradlew
├── gradlew.bat
├── local.properties
└── settings.gradle
Level Up Your Android Build - droidcon Berlin 2015
Gradle wrapper
$ ./gradlew tasks
Level Up Your Android Build - droidcon Berlin 2015
Gradle wrapper
$ gw clean ass
Level Up Your Android Build - droidcon Berlin 2015
Using a Gradle plugin
build.gradle (root folder)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.novoda:gradle-android-command-plugin:1.4.0'
}
}
apply plugin: 'com.novoda.android-command'
$ gw runDebug
Level Up Your Android Build - droidcon Berlin 2015
Dependencies
dependencies {
apt 'com.google.dagger:dagger-compiler:2.0'
compile 'com.google.dagger:dagger:2.0'
compile 'com.google.guava:guava:18.0'
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
}
Level Up Your Android Build - droidcon Berlin 2015
Dependencies
dependencies {
apt 'com.google.dagger:dagger-compiler:2.0'
compile 'com.google.dagger:dagger:2.0'
compile 'com.google.guava:guava:18.0'
paidCompile project(':lvl')
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.9.5'
}
Level Up Your Android Build - droidcon Berlin 2015
Flavors (free - paid)
Level Up Your Android Build - droidcon Berlin 2015
Proguard
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'),
'proguard.cfg'
}
}
proguard.cfg
#Dagger2
-dontwarn dagger.shaded.auto.common.**
-dontwarn dagger.internal.codegen.**
-keepattributes Signature
Level Up Your Android Build - droidcon Berlin 2015
Archive Release
ext.VERSION_NAME=1.0.0
task archiveRelease(type: Copy) {
from 'build/outputs/apk', 'build/outputs/'
into "releases/${VERSION_CODE}"
include('android-release.apk', 'mapping/**')
rename ('android-release.apk', "${APP_NAME}
_${BUILD_DATE}_${VERSION_NAME}_${VERSION_CODE}.apk")
}
Level Up Your Android Build - droidcon Berlin 2015
image
Level Up Your Android Build - droidcon Berlin 2015
image
Level Up Your Android Build - droidcon Berlin 2015
Scaling up
● re-use
● testing
● quality assurance
● continuous integration
Level Up Your Android Build - droidcon Berlin 2015
Re-use - Core project
gradle init --type java-library
dependencies {
compile project(':model')
}
Level Up Your Android Build - droidcon Berlin 2015
Re-use - Core project
gradle init --type java-library
dependencies {
compile project(':model')
}
gradle init --type groovy-library
println new URL('http://www.google.com').text
Level Up Your Android Build - droidcon Berlin 2015
Separation - Integration Tests for Java
sourceSets {
integrationTest {
java { srcDir 'src/integrationtest/java' }
resources { srcDir 'src/integrationtest/resources' }
compileClasspath += sourceSets.main.runtimeClasspath
}
}
task integrationTest(type: Test) {
testClassesDir =
sourceSets.integrationTest.output.classesDir
classpath += sourceSets.integrationTest.runtimeClasspath
}
Level Up Your Android Build - droidcon Berlin 2015
Keep Up To Date
gw dependencyUpdates
The following dependencies have later milestone versions:
- com.fasterxml.jackson.core:jackson-annotations [2.1.2 -> 2.6.0-rc1]
- com.fasterxml.jackson.core:jackson-core [2.1.1 -> 2.6.0-rc1]
- com.fasterxml.jackson.core:jackson-databind [2.1.2 -> 2.6.0-rc1]
- com.github.kevinsawicki:http-request [4.0 -> 9.9]
- joda-time:joda-time [2.3 -> 2.8]
- org.mockito:mockito-core [1.9.0 -> 2.0.8-beta]
Generated report file build/dependencyUpdates/report.txt
Level Up Your Android Build - droidcon Berlin 2015
Code Quality Tools
apply plugin: 'checkstyle'
task checkstyleMain(type: Checkstyle) {
description 'Checks whether code complies with coding rules.'
ignoreFailures !project.failFastOnError
...
doLast {
if (project.hasProperty('checkstyle.html')) {
ant.xslt(in: reports.xml.destination,
style: file("$rulesDir/checkstyle/noframes-sorted.xsl"),
out: new File(reports.xml.destination.parent,
name - 'checkstyle' + '.html'))
}
}
}
Level Up Your Android Build - droidcon Berlin 2015
Code Quality Tools
apply plugin: 'checkstyle'
task checkstyleMain(type: Checkstyle) {
description 'Checks whether code complies with coding rules.'
ignoreFailures !project.failFastOnError
...
doLast {
if (project.hasProperty('checkstyle.html')) {
ant.xslt(in: reports.xml.destination,
style: file("$rulesDir/checkstyle/noframes-sorted.xsl"),
out: new File(reports.xml.destination.parent,
name - 'checkstyle' + '.html'))
}
}
}
gw checkstyleMain -PfailFastOnError -Pcheckstyle.html
Level Up Your Android Build - droidcon Berlin 2015
Code Quality Tools
apply plugin: 'checkstyle'
task checkstyleMain(type: Checkstyle) {
description 'Checks whether code complies with coding rules.'
ignoreFailures !project.failFastOnError
...
doLast {
if (project.hasProperty('checkstyle.html')) {
ant.xslt(in: reports.xml.destination,
style: file("$rulesDir/checkstyle/noframes-sorted.xsl"),
out: new File(reports.xml.destination.parent,
name - 'checkstyle' + '.html'))
}
}
}
Level Up Your Android Build - droidcon Berlin 2015
Continuous Integration
System.getenv("...")
Jenkins
BUILD_NUMBER
Travis
TRAVIS_BUILD_NUMBER
Level Up Your Android Build - droidcon Berlin 2015
Connected Tests on CI
task filterTestDevices << {
com.android.builder.testing.ConnectedDeviceProvider.metaClass
.getDevices = {
localDevices
.findAll { it.iDevice.online }
.findAll { !it.getProperty('ro.build.characteristics')
?.toLowerCase()?.contains('tablet') }
.unique { it.apiLevel }
}
}
Level Up Your Android Build - droidcon Berlin 2015
Connected Tests on CI
afterEvaluate {
project.tasks.findAll {
it.name.startsWith('connectedAndroidTest')
}*.dependsOn filterTestDevices
}
Level Up Your Android Build - droidcon Berlin 2015
Releasing from CI
● update Version
● commit changes
● upload to Stores
Level Up Your Android Build - droidcon Berlin 2015
Release from CI - Versioning
def versionFile = file('version.properties')
Version version = Version.read(versionFile)
task incrementVersion << {
Version.increment(versionFile)
}
Level Up Your Android Build - droidcon Berlin 2015
Release from CI - Versioning
def versionFile = file('version.properties')
Version version = Version.read(versionFile)
task incrementVersion << {
description = 'Increases the version'
Version.increment(versionFile)
}
buildSrc/
└── src
└── main
└── groovy
└── Version.groovy
Level Up Your Android Build - droidcon Berlin 2015
Release from CI - git
buildscript {
dependencies {
classpath 'org.ajoberstar:grgit:1.1.0'
}
}
ext {
git = org.ajoberstar.grgit.Grgit.open(
rootProject.file('.'))
}
def sha = git.head().abbreviatedId
git.add 'version.properties'
git.commit(message: "Bumping version to $VERSION_CODE")
git.push()
Level Up Your Android Build - droidcon Berlin 2015
Publishing - Google Play
play-publisher-plugin by triple-t
● bootstrapReleasePlayResources - Fetch all existing data from the Play
Store to bootstrap the required files and folders.
● publishApkRelease - Uploads the APK and the summary of recent
changes.
● publishListingRelease - Uploads the descriptions and images for the Play
Store listing.
● publishRelease - Uploads everything.
Level Up Your Android Build - droidcon Berlin 2015
Publishing - Google Play
play-publisher-plugin by triple-t
● bootstrapReleasePlayResources - Fetch all existing data from the Play
Store to bootstrap the required files and folders.
● publishApkRelease - Uploads the APK and the summary of recent
changes.
● publishListingRelease - Uploads the descriptions and images for the Play
Store listing.
● publishRelease - Uploads everything.play {
serviceAccountEmail = 'your-service-account-email'
pk12File = file('key.p12')
}
Level Up Your Android Build - droidcon Berlin 2015
Publishing - Other App Stores
task createAppDFs {
android.applicationVariants.all { variant ->
if (variant.buildType.name == "release")
createAppDF(variant.name)
}
}
Level Up Your Android Build - droidcon Berlin 2015
Advanced - Complex Build Scripts
share common configuration data via root subfolder
File shared(String relativeFilePath) {
file("shared/$relativeFilePath")
}
share common dependencies via root build.gradle
ext {
guavaDependency = 'com.google.guava:guava:18.0'
...
}
use it in sub-projects via:
dependencies {
compile guavaDependency
...
}
Level Up Your Android Build - droidcon Berlin 2015
Advanced - Shrink
dependencies {
classpath 'net.sf.proguard:proguard-gradle:4.11'
}
...
task shrinkGuava(type: proguard.gradle.ProGuardTask) {
injars configurations.injar.files
libraryjars configurations.libjar.files
outjars file("build/libs/guava_${guavaVersion}_base.jar")
configuration "guava.proguard"
}
guava.proguard:
-dontoptimize
-dontobfuscate
-keep public class com.google.common.base.** { public *; }
Level Up Your Android Build - droidcon Berlin 2015
Advanced - Sync images
task syncPhotos(type: com.novoda.gradle.command.Files) {
deviceId {
def moto = android.command.devices().find { it.brand() == 'motorola' }
if (!moto) { throw new GroovyRuntimeException('No Motorola device') }
moto.id
}
script {
def backupDir = mkdir('motoPhoto')
list('/sdcard/DCIM/Camera/').findAll { image ->
!new File(backupDir.path, image.name).exists()
}.each { image ->
pull image.path + image.name, backupDir.path
}
}
}
Level Up Your Android Build - droidcon Berlin 2015
Advanced - Sqlite Access
sqliteAccess {
migrationsDir 'src/main/assets/migrations'
packageName 'com.novoda.sqliteprovider.demo.simple'
generator { database, basedir ->
def access = access(database)
// …, adjust access model as needed
generateClass(file('code.template'), access, "DB",
packageName, basedir)
}
}
Level Up Your Android Build - droidcon Berlin 2015
Advanced - Sqlite Access
code.template
package $packageName;
public final class $className {
public static final class Tables {
<% access.tables.each { dataSet -> %>
public static final String $dataSet.name = "$dataSet.sqlName";
<% } %>
}
...
}
Level Up Your Android Build - droidcon Berlin 2015
Advanced - Groovy on Android
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.6'
}
}
apply plugin: 'groovyx.grooid.groovy-android'
dependencies {
compile 'org.codehaus.groovy:groovy:2.4.3:grooid'
}
Level Up Your Android Build - droidcon Berlin 2015
Resources (in order of appearance)
Android plugin for Gradle
https://developer.android.com/tools/building/plugin-for-gradle.html
gdub Tool
https://github.com/dougborg/gdub
apt Plugin
https://bitbucket.org/hvisser/android-apt
Command Plugin
https://github.com/novoda/gradle-android-command-plugin
Gradle Plugin Portal
http://plugins.gradle.org
Level Up Your Android Build - droidcon Berlin 2015
Resources (in order of appearance)
Proguard Annotation Squadleader
https://bitbucket.org/littlerobots/squadleader
Proguard Snippets
https://github.com/krschultz/android-proguard-snippets
Gradle Udacity Course
https://www.udacity.com/wiki/ud867
Groovy library for git
https://github.com/ajoberstar/grgit
Level Up Your Android Build - droidcon Berlin 2015
Resources (in order of appearance)
Soter Plugin
https://github.com/dlabs/soter
Shrink Guava Script Snippet
https://gist.github.com/devisnik/e54ea0a629adc82bcfa0
Groovy Android Plugin
https://github.com/groovy/groovy-android-gradle-plugin
Sqlite Analyzer Plugin
https://github.com/novoda/sqlite-analyzer
Level Up Your Android Build - droidcon Berlin 2015
TDTD - Tester-Driven Talk Development
Thanks to the folks from Android
Stammtisch Berlin for serving as Testers
for a lot of the presented material.
Upcoming book:
Growing Subject-Oriented Talks,
Guided by Testers
Level Up Your Android Build - droidcon Berlin 2015
Friedger Müffke Volker Leck
fmdroid devisnik
+FriedgerMüffke +VolkerLeck
friedger devisnik
Level Up Your Android Build - droidcon Berlin 2015
Build tooling
Level Up Your Android Build - droidcon Berlin 2015
Problems
● no re-use outside android app
● limited and manual code quality assurance (via test feedback)
● limited automation
○ manual versioning
○ manual deployment
○ no continuous integration
○ tedious distribution (beta channels, bug tracking, ..)
○ dependent on Android SDK installation
Level Up Your Android Build - droidcon Berlin 2015
Separation - Test Execution
test {
useJUnit {
excludeCategories 'com.sample.api.LiveTest'
}
}
task endpointTest(type: Test, dependsOn: testClasses) {
useJUnit {
includeCategories 'com.sample.api.LiveTest'
}
}
annotate tests with: @Category(LiveTest.class)

More Related Content

What's hot

Integration testing for microservices with Spring Boot
Integration testing for microservices with Spring BootIntegration testing for microservices with Spring Boot
Integration testing for microservices with Spring BootOleksandr Romanov
 
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & morePower your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & morewesley chun
 
AOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java PlatformAOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java PlatformPeter Pilgrim
 
Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Fafadia Tech
 
#BABBQAmsterdam The other Android getting started guide: Gradle power
#BABBQAmsterdam The other Android getting started guide: Gradle power#BABBQAmsterdam The other Android getting started guide: Gradle power
#BABBQAmsterdam The other Android getting started guide: Gradle powerJavier de Pedro López
 
Flows - what you should know before implementing
Flows - what you should know before implementingFlows - what you should know before implementing
Flows - what you should know before implementingDoria Hamelryk
 
Gradle: One technology to build them all
Gradle: One technology to build them allGradle: One technology to build them all
Gradle: One technology to build them allBonitasoft
 
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)pycontw
 
Yaml as Pipeline GSoC 218 Phase 2 evaluation
Yaml as Pipeline GSoC 218 Phase 2 evaluationYaml as Pipeline GSoC 218 Phase 2 evaluation
Yaml as Pipeline GSoC 218 Phase 2 evaluationAbhishek Gautam
 

What's hot (11)

Integration testing for microservices with Spring Boot
Integration testing for microservices with Spring BootIntegration testing for microservices with Spring Boot
Integration testing for microservices with Spring Boot
 
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & morePower your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
Power your apps with Gmail, Google Drive, Calendar, Sheets, Slides & more
 
Active x
Active xActive x
Active x
 
AOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java PlatformAOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java Platform
 
201801 SER332 Lecture 03
201801 SER332 Lecture 03201801 SER332 Lecture 03
201801 SER332 Lecture 03
 
Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)Introduction To Google Android (Ft Rohan Bomle)
Introduction To Google Android (Ft Rohan Bomle)
 
#BABBQAmsterdam The other Android getting started guide: Gradle power
#BABBQAmsterdam The other Android getting started guide: Gradle power#BABBQAmsterdam The other Android getting started guide: Gradle power
#BABBQAmsterdam The other Android getting started guide: Gradle power
 
Flows - what you should know before implementing
Flows - what you should know before implementingFlows - what you should know before implementing
Flows - what you should know before implementing
 
Gradle: One technology to build them all
Gradle: One technology to build them allGradle: One technology to build them all
Gradle: One technology to build them all
 
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
STAF 在自動化測試上的延伸應用 -- TMSTAF (TrendMicro STAF)
 
Yaml as Pipeline GSoC 218 Phase 2 evaluation
Yaml as Pipeline GSoC 218 Phase 2 evaluationYaml as Pipeline GSoC 218 Phase 2 evaluation
Yaml as Pipeline GSoC 218 Phase 2 evaluation
 

Viewers also liked

Delegating user tasks in applications
Delegating user tasks in applicationsDelegating user tasks in applications
Delegating user tasks in applicationsFriedger Müffke
 
Open Governance in Mobile - SFD 2013 - HSBXL
Open Governance in Mobile -  SFD 2013 - HSBXLOpen Governance in Mobile -  SFD 2013 - HSBXL
Open Governance in Mobile - SFD 2013 - HSBXLFriedger Müffke
 
Web Wishes, Intents, Extensions, .. Friedger Müffke, droidcon London 2014
Web Wishes, Intents, Extensions, ..  Friedger Müffke, droidcon London 2014Web Wishes, Intents, Extensions, ..  Friedger Müffke, droidcon London 2014
Web Wishes, Intents, Extensions, .. Friedger Müffke, droidcon London 2014Friedger Müffke
 
Open intents Aggregating Apps
Open intents Aggregating AppsOpen intents Aggregating Apps
Open intents Aggregating AppsFriedger Müffke
 
Android Evolution, AppForum 2014, Brussels, Friedger Müffke
Android Evolution, AppForum 2014, Brussels, Friedger MüffkeAndroid Evolution, AppForum 2014, Brussels, Friedger Müffke
Android Evolution, AppForum 2014, Brussels, Friedger MüffkeFriedger Müffke
 
UXperts 2012: Connectivity Beyond the Web (Android), Friedger Müffke
UXperts 2012: Connectivity Beyond the Web (Android), Friedger MüffkeUXperts 2012: Connectivity Beyond the Web (Android), Friedger Müffke
UXperts 2012: Connectivity Beyond the Web (Android), Friedger MüffkeFriedger Müffke
 
Google Integration in Android Apps - Mooscon 2013 Cebit
Google Integration in Android Apps - Mooscon 2013 CebitGoogle Integration in Android Apps - Mooscon 2013 Cebit
Google Integration in Android Apps - Mooscon 2013 CebitFriedger Müffke
 
Serverless Apps - droidcon london 2012
Serverless Apps - droidcon london 2012Serverless Apps - droidcon london 2012
Serverless Apps - droidcon london 2012Friedger Müffke
 

Viewers also liked (8)

Delegating user tasks in applications
Delegating user tasks in applicationsDelegating user tasks in applications
Delegating user tasks in applications
 
Open Governance in Mobile - SFD 2013 - HSBXL
Open Governance in Mobile -  SFD 2013 - HSBXLOpen Governance in Mobile -  SFD 2013 - HSBXL
Open Governance in Mobile - SFD 2013 - HSBXL
 
Web Wishes, Intents, Extensions, .. Friedger Müffke, droidcon London 2014
Web Wishes, Intents, Extensions, ..  Friedger Müffke, droidcon London 2014Web Wishes, Intents, Extensions, ..  Friedger Müffke, droidcon London 2014
Web Wishes, Intents, Extensions, .. Friedger Müffke, droidcon London 2014
 
Open intents Aggregating Apps
Open intents Aggregating AppsOpen intents Aggregating Apps
Open intents Aggregating Apps
 
Android Evolution, AppForum 2014, Brussels, Friedger Müffke
Android Evolution, AppForum 2014, Brussels, Friedger MüffkeAndroid Evolution, AppForum 2014, Brussels, Friedger Müffke
Android Evolution, AppForum 2014, Brussels, Friedger Müffke
 
UXperts 2012: Connectivity Beyond the Web (Android), Friedger Müffke
UXperts 2012: Connectivity Beyond the Web (Android), Friedger MüffkeUXperts 2012: Connectivity Beyond the Web (Android), Friedger Müffke
UXperts 2012: Connectivity Beyond the Web (Android), Friedger Müffke
 
Google Integration in Android Apps - Mooscon 2013 Cebit
Google Integration in Android Apps - Mooscon 2013 CebitGoogle Integration in Android Apps - Mooscon 2013 Cebit
Google Integration in Android Apps - Mooscon 2013 Cebit
 
Serverless Apps - droidcon london 2012
Serverless Apps - droidcon london 2012Serverless Apps - droidcon london 2012
Serverless Apps - droidcon london 2012
 

Similar to Level Up Your Android Build -Droidcon Berlin 2015

Getting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle pluginGetting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle plugintobiaspreuss
 
Mastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
Mastering the NDK with Android Studio 2.0 and the gradle-experimental pluginMastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
Mastering the NDK with Android Studio 2.0 and the gradle-experimental pluginXavier Hallade
 
Hacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdfHacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdfShaiAlmog1
 
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023Nicolas HAAN
 
[DEPRECATED]Gradle the android
[DEPRECATED]Gradle the android[DEPRECATED]Gradle the android
[DEPRECATED]Gradle the androidJun Liu
 
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018Somkiat Khitwongwattana
 
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...Dicoding
 
7 Ways to improve your gradle build
7 Ways to improve your gradle build7 Ways to improve your gradle build
7 Ways to improve your gradle buildTania Pinheiro
 
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...Infinum
 
DMCA #25: Jenkins - Docker & Android: Comment Docker peu faciliter la créatio...
DMCA #25: Jenkins - Docker & Android: Comment Docker peu faciliter la créatio...DMCA #25: Jenkins - Docker & Android: Comment Docker peu faciliter la créatio...
DMCA #25: Jenkins - Docker & Android: Comment Docker peu faciliter la créatio...Olivier Destrebecq
 
Building an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and FirebaseBuilding an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and FirebaseMarina Coelho
 
Intro to Gradle + How to get up to speed
Intro to Gradle + How to get up to speedIntro to Gradle + How to get up to speed
Intro to Gradle + How to get up to speedReid Baker
 
Build pipelines with TeamCity and Kotlin DSL
Build pipelines with TeamCity and Kotlin DSLBuild pipelines with TeamCity and Kotlin DSL
Build pipelines with TeamCity and Kotlin DSLAnton Arhipov
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StoryKon Soulianidis
 
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...COMAQA.BY
 
Android gradle-build-system-overview
Android gradle-build-system-overviewAndroid gradle-build-system-overview
Android gradle-build-system-overviewKevin He
 
Android installation guide
Android installation guideAndroid installation guide
Android installation guidemagicshui
 

Similar to Level Up Your Android Build -Droidcon Berlin 2015 (20)

Enter the gradle
Enter the gradleEnter the gradle
Enter the gradle
 
Gradle presentation
Gradle presentationGradle presentation
Gradle presentation
 
Getting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle pluginGetting started with building your own standalone Gradle plugin
Getting started with building your own standalone Gradle plugin
 
Mastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
Mastering the NDK with Android Studio 2.0 and the gradle-experimental pluginMastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
Mastering the NDK with Android Studio 2.0 and the gradle-experimental plugin
 
Hacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdfHacking the Codename One Source Code - Part IV - Transcript.pdf
Hacking the Codename One Source Code - Part IV - Transcript.pdf
 
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
Comment développer une application mobile en 8 semaines - Meetup PAUG 24-01-2023
 
[DEPRECATED]Gradle the android
[DEPRECATED]Gradle the android[DEPRECATED]Gradle the android
[DEPRECATED]Gradle the android
 
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
Hello, Android Studio 3.2 & Android App Bundle @ I/O Extended Bangkok 2018
 
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
ID Android TechTalk Series #6 : Google Service and Gradle - Anton Nurdin Tuha...
 
7 Ways to improve your gradle build
7 Ways to improve your gradle build7 Ways to improve your gradle build
7 Ways to improve your gradle build
 
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
Infinum Android Talks #14 - Data binding to the rescue... or not (?) by Krist...
 
OpenCms Days 2012 - Developing OpenCms with Gradle
OpenCms Days 2012 - Developing OpenCms with GradleOpenCms Days 2012 - Developing OpenCms with Gradle
OpenCms Days 2012 - Developing OpenCms with Gradle
 
DMCA #25: Jenkins - Docker & Android: Comment Docker peu faciliter la créatio...
DMCA #25: Jenkins - Docker & Android: Comment Docker peu faciliter la créatio...DMCA #25: Jenkins - Docker & Android: Comment Docker peu faciliter la créatio...
DMCA #25: Jenkins - Docker & Android: Comment Docker peu faciliter la créatio...
 
Building an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and FirebaseBuilding an Android app with Jetpack Compose and Firebase
Building an Android app with Jetpack Compose and Firebase
 
Intro to Gradle + How to get up to speed
Intro to Gradle + How to get up to speedIntro to Gradle + How to get up to speed
Intro to Gradle + How to get up to speed
 
Build pipelines with TeamCity and Kotlin DSL
Build pipelines with TeamCity and Kotlin DSLBuild pipelines with TeamCity and Kotlin DSL
Build pipelines with TeamCity and Kotlin DSL
 
Single Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle StorySingle Page JavaScript WebApps... A Gradle Story
Single Page JavaScript WebApps... A Gradle Story
 
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
Дмитрий Лемешко. Comaqa Spring 2018. Continuous mobile automation in build pi...
 
Android gradle-build-system-overview
Android gradle-build-system-overviewAndroid gradle-build-system-overview
Android gradle-build-system-overview
 
Android installation guide
Android installation guideAndroid installation guide
Android installation guide
 

More from Friedger Müffke

Open intents Open Governance
Open intents Open GovernanceOpen intents Open Governance
Open intents Open GovernanceFriedger Müffke
 
Highlights Google I/O 2011
Highlights Google I/O 2011Highlights Google I/O 2011
Highlights Google I/O 2011Friedger Müffke
 
Open Android Apps - Hidden Treasures on Android phones
Open Android Apps - Hidden Treasures on Android phonesOpen Android Apps - Hidden Treasures on Android phones
Open Android Apps - Hidden Treasures on Android phonesFriedger Müffke
 
Google Workshop at International Congress of Youth Enterpreneurship by Friedg...
Google Workshop at International Congress of Youth Enterpreneurship by Friedg...Google Workshop at International Congress of Youth Enterpreneurship by Friedg...
Google Workshop at International Congress of Youth Enterpreneurship by Friedg...Friedger Müffke
 
Open intents, open apps and dependencies
Open intents, open apps and dependenciesOpen intents, open apps and dependencies
Open intents, open apps and dependenciesFriedger Müffke
 
App inventor for android and similar tools
App inventor for android and similar toolsApp inventor for android and similar tools
App inventor for android and similar toolsFriedger Müffke
 
Open Intents And Dependencies
Open Intents And DependenciesOpen Intents And Dependencies
Open Intents And DependenciesFriedger Müffke
 
Open Intents - Android Intents Mechanism and Dependency Management
Open Intents - Android Intents Mechanism and Dependency ManagementOpen Intents - Android Intents Mechanism and Dependency Management
Open Intents - Android Intents Mechanism and Dependency ManagementFriedger Müffke
 

More from Friedger Müffke (9)

Open intents Open Governance
Open intents Open GovernanceOpen intents Open Governance
Open intents Open Governance
 
Highlights Google I/O 2011
Highlights Google I/O 2011Highlights Google I/O 2011
Highlights Google I/O 2011
 
Open Android Apps - Hidden Treasures on Android phones
Open Android Apps - Hidden Treasures on Android phonesOpen Android Apps - Hidden Treasures on Android phones
Open Android Apps - Hidden Treasures on Android phones
 
Google Workshop at International Congress of Youth Enterpreneurship by Friedg...
Google Workshop at International Congress of Youth Enterpreneurship by Friedg...Google Workshop at International Congress of Youth Enterpreneurship by Friedg...
Google Workshop at International Congress of Youth Enterpreneurship by Friedg...
 
Open intents, open apps and dependencies
Open intents, open apps and dependenciesOpen intents, open apps and dependencies
Open intents, open apps and dependencies
 
Glass
GlassGlass
Glass
 
App inventor for android and similar tools
App inventor for android and similar toolsApp inventor for android and similar tools
App inventor for android and similar tools
 
Open Intents And Dependencies
Open Intents And DependenciesOpen Intents And Dependencies
Open Intents And Dependencies
 
Open Intents - Android Intents Mechanism and Dependency Management
Open Intents - Android Intents Mechanism and Dependency ManagementOpen Intents - Android Intents Mechanism and Dependency Management
Open Intents - Android Intents Mechanism and Dependency Management
 

Recently uploaded

CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual serviceanilsa9823
 
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRFULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRnishacall1
 
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,Pooja Nehwal
 
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun serviceanilsa9823
 
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPowerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPsychicRuben LoveSpells
 
9892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x79892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x7Pooja Nehwal
 

Recently uploaded (7)

CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual serviceCALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
CALL ON ➥8923113531 🔝Call Girls Saharaganj Lucknow best sexual service
 
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCRFULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
FULL ENJOY - 9999218229 Call Girls in {Mahipalpur}| Delhi NCR
 
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
Call US Pooja 9892124323 ✓Call Girls In Mira Road ( Mumbai ) secure service,
 
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 71 Noida Escorts >༒8448380779 Escort Service
 
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun serviceCALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
CALL ON ➥8923113531 🔝Call Girls Gomti Nagar Lucknow best Night Fun service
 
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost LoverPowerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
Powerful Love Spells in Arkansas, AR (310) 882-6330 Bring Back Lost Lover
 
9892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x79892124323 | Book Call Girls in Juhu and escort services 24x7
9892124323 | Book Call Girls in Juhu and escort services 24x7
 

Level Up Your Android Build -Droidcon Berlin 2015

  • 1. Level Up Your Android Build - droidcon Berlin 2015 LEVEL UP YOUR ANDROID BUILD Volker Leck Friedger Müffke Droidcon Berlin 2015
  • 2. Level Up Your Android Build - droidcon Berlin 2015 image
  • 3. Level Up Your Android Build - droidcon Berlin 2015 image Phoogle Gotos
  • 4. Level Up Your Android Build - droidcon Berlin 2015 app/build.gradle apply plugin: 'com.android.application' android { compileSdkVersion 22 buildToolsVersion "22.2.0" defaultConfig { ... } buildTypes { release { ... } } } dependencies { ... }
  • 5. Level Up Your Android Build - droidcon Berlin 2015 Relevant Build Files ├── app │ └── build.gradle ├── build.gradle ├── gradle │ └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── gradlew ├── gradlew.bat ├── local.properties └── settings.gradle
  • 6. Level Up Your Android Build - droidcon Berlin 2015 Gradle wrapper $ ./gradlew tasks
  • 7. Level Up Your Android Build - droidcon Berlin 2015 Gradle wrapper $ gw clean ass
  • 8. Level Up Your Android Build - droidcon Berlin 2015 Using a Gradle plugin build.gradle (root folder) buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' classpath 'com.novoda:gradle-android-command-plugin:1.4.0' } } apply plugin: 'com.novoda.android-command' $ gw runDebug
  • 9. Level Up Your Android Build - droidcon Berlin 2015 Dependencies dependencies { apt 'com.google.dagger:dagger-compiler:2.0' compile 'com.google.dagger:dagger:2.0' compile 'com.google.guava:guava:18.0' testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.9.5' }
  • 10. Level Up Your Android Build - droidcon Berlin 2015 Dependencies dependencies { apt 'com.google.dagger:dagger-compiler:2.0' compile 'com.google.dagger:dagger:2.0' compile 'com.google.guava:guava:18.0' paidCompile project(':lvl') testCompile 'junit:junit:4.12' testCompile 'org.mockito:mockito-core:1.9.5' }
  • 11. Level Up Your Android Build - droidcon Berlin 2015 Flavors (free - paid)
  • 12. Level Up Your Android Build - droidcon Berlin 2015 Proguard buildTypes { release { minifyEnabled true shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.cfg' } } proguard.cfg #Dagger2 -dontwarn dagger.shaded.auto.common.** -dontwarn dagger.internal.codegen.** -keepattributes Signature
  • 13. Level Up Your Android Build - droidcon Berlin 2015 Archive Release ext.VERSION_NAME=1.0.0 task archiveRelease(type: Copy) { from 'build/outputs/apk', 'build/outputs/' into "releases/${VERSION_CODE}" include('android-release.apk', 'mapping/**') rename ('android-release.apk', "${APP_NAME} _${BUILD_DATE}_${VERSION_NAME}_${VERSION_CODE}.apk") }
  • 14. Level Up Your Android Build - droidcon Berlin 2015 image
  • 15. Level Up Your Android Build - droidcon Berlin 2015 image
  • 16. Level Up Your Android Build - droidcon Berlin 2015 Scaling up ● re-use ● testing ● quality assurance ● continuous integration
  • 17. Level Up Your Android Build - droidcon Berlin 2015 Re-use - Core project gradle init --type java-library dependencies { compile project(':model') }
  • 18. Level Up Your Android Build - droidcon Berlin 2015 Re-use - Core project gradle init --type java-library dependencies { compile project(':model') } gradle init --type groovy-library println new URL('http://www.google.com').text
  • 19. Level Up Your Android Build - droidcon Berlin 2015 Separation - Integration Tests for Java sourceSets { integrationTest { java { srcDir 'src/integrationtest/java' } resources { srcDir 'src/integrationtest/resources' } compileClasspath += sourceSets.main.runtimeClasspath } } task integrationTest(type: Test) { testClassesDir = sourceSets.integrationTest.output.classesDir classpath += sourceSets.integrationTest.runtimeClasspath }
  • 20. Level Up Your Android Build - droidcon Berlin 2015 Keep Up To Date gw dependencyUpdates The following dependencies have later milestone versions: - com.fasterxml.jackson.core:jackson-annotations [2.1.2 -> 2.6.0-rc1] - com.fasterxml.jackson.core:jackson-core [2.1.1 -> 2.6.0-rc1] - com.fasterxml.jackson.core:jackson-databind [2.1.2 -> 2.6.0-rc1] - com.github.kevinsawicki:http-request [4.0 -> 9.9] - joda-time:joda-time [2.3 -> 2.8] - org.mockito:mockito-core [1.9.0 -> 2.0.8-beta] Generated report file build/dependencyUpdates/report.txt
  • 21. Level Up Your Android Build - droidcon Berlin 2015 Code Quality Tools apply plugin: 'checkstyle' task checkstyleMain(type: Checkstyle) { description 'Checks whether code complies with coding rules.' ignoreFailures !project.failFastOnError ... doLast { if (project.hasProperty('checkstyle.html')) { ant.xslt(in: reports.xml.destination, style: file("$rulesDir/checkstyle/noframes-sorted.xsl"), out: new File(reports.xml.destination.parent, name - 'checkstyle' + '.html')) } } }
  • 22. Level Up Your Android Build - droidcon Berlin 2015 Code Quality Tools apply plugin: 'checkstyle' task checkstyleMain(type: Checkstyle) { description 'Checks whether code complies with coding rules.' ignoreFailures !project.failFastOnError ... doLast { if (project.hasProperty('checkstyle.html')) { ant.xslt(in: reports.xml.destination, style: file("$rulesDir/checkstyle/noframes-sorted.xsl"), out: new File(reports.xml.destination.parent, name - 'checkstyle' + '.html')) } } } gw checkstyleMain -PfailFastOnError -Pcheckstyle.html
  • 23. Level Up Your Android Build - droidcon Berlin 2015 Code Quality Tools apply plugin: 'checkstyle' task checkstyleMain(type: Checkstyle) { description 'Checks whether code complies with coding rules.' ignoreFailures !project.failFastOnError ... doLast { if (project.hasProperty('checkstyle.html')) { ant.xslt(in: reports.xml.destination, style: file("$rulesDir/checkstyle/noframes-sorted.xsl"), out: new File(reports.xml.destination.parent, name - 'checkstyle' + '.html')) } } }
  • 24. Level Up Your Android Build - droidcon Berlin 2015 Continuous Integration System.getenv("...") Jenkins BUILD_NUMBER Travis TRAVIS_BUILD_NUMBER
  • 25. Level Up Your Android Build - droidcon Berlin 2015 Connected Tests on CI task filterTestDevices << { com.android.builder.testing.ConnectedDeviceProvider.metaClass .getDevices = { localDevices .findAll { it.iDevice.online } .findAll { !it.getProperty('ro.build.characteristics') ?.toLowerCase()?.contains('tablet') } .unique { it.apiLevel } } }
  • 26. Level Up Your Android Build - droidcon Berlin 2015 Connected Tests on CI afterEvaluate { project.tasks.findAll { it.name.startsWith('connectedAndroidTest') }*.dependsOn filterTestDevices }
  • 27. Level Up Your Android Build - droidcon Berlin 2015 Releasing from CI ● update Version ● commit changes ● upload to Stores
  • 28. Level Up Your Android Build - droidcon Berlin 2015 Release from CI - Versioning def versionFile = file('version.properties') Version version = Version.read(versionFile) task incrementVersion << { Version.increment(versionFile) }
  • 29. Level Up Your Android Build - droidcon Berlin 2015 Release from CI - Versioning def versionFile = file('version.properties') Version version = Version.read(versionFile) task incrementVersion << { description = 'Increases the version' Version.increment(versionFile) } buildSrc/ └── src └── main └── groovy └── Version.groovy
  • 30. Level Up Your Android Build - droidcon Berlin 2015 Release from CI - git buildscript { dependencies { classpath 'org.ajoberstar:grgit:1.1.0' } } ext { git = org.ajoberstar.grgit.Grgit.open( rootProject.file('.')) } def sha = git.head().abbreviatedId git.add 'version.properties' git.commit(message: "Bumping version to $VERSION_CODE") git.push()
  • 31. Level Up Your Android Build - droidcon Berlin 2015 Publishing - Google Play play-publisher-plugin by triple-t ● bootstrapReleasePlayResources - Fetch all existing data from the Play Store to bootstrap the required files and folders. ● publishApkRelease - Uploads the APK and the summary of recent changes. ● publishListingRelease - Uploads the descriptions and images for the Play Store listing. ● publishRelease - Uploads everything.
  • 32. Level Up Your Android Build - droidcon Berlin 2015 Publishing - Google Play play-publisher-plugin by triple-t ● bootstrapReleasePlayResources - Fetch all existing data from the Play Store to bootstrap the required files and folders. ● publishApkRelease - Uploads the APK and the summary of recent changes. ● publishListingRelease - Uploads the descriptions and images for the Play Store listing. ● publishRelease - Uploads everything.play { serviceAccountEmail = 'your-service-account-email' pk12File = file('key.p12') }
  • 33. Level Up Your Android Build - droidcon Berlin 2015 Publishing - Other App Stores task createAppDFs { android.applicationVariants.all { variant -> if (variant.buildType.name == "release") createAppDF(variant.name) } }
  • 34. Level Up Your Android Build - droidcon Berlin 2015 Advanced - Complex Build Scripts share common configuration data via root subfolder File shared(String relativeFilePath) { file("shared/$relativeFilePath") } share common dependencies via root build.gradle ext { guavaDependency = 'com.google.guava:guava:18.0' ... } use it in sub-projects via: dependencies { compile guavaDependency ... }
  • 35. Level Up Your Android Build - droidcon Berlin 2015 Advanced - Shrink dependencies { classpath 'net.sf.proguard:proguard-gradle:4.11' } ... task shrinkGuava(type: proguard.gradle.ProGuardTask) { injars configurations.injar.files libraryjars configurations.libjar.files outjars file("build/libs/guava_${guavaVersion}_base.jar") configuration "guava.proguard" } guava.proguard: -dontoptimize -dontobfuscate -keep public class com.google.common.base.** { public *; }
  • 36. Level Up Your Android Build - droidcon Berlin 2015 Advanced - Sync images task syncPhotos(type: com.novoda.gradle.command.Files) { deviceId { def moto = android.command.devices().find { it.brand() == 'motorola' } if (!moto) { throw new GroovyRuntimeException('No Motorola device') } moto.id } script { def backupDir = mkdir('motoPhoto') list('/sdcard/DCIM/Camera/').findAll { image -> !new File(backupDir.path, image.name).exists() }.each { image -> pull image.path + image.name, backupDir.path } } }
  • 37. Level Up Your Android Build - droidcon Berlin 2015 Advanced - Sqlite Access sqliteAccess { migrationsDir 'src/main/assets/migrations' packageName 'com.novoda.sqliteprovider.demo.simple' generator { database, basedir -> def access = access(database) // …, adjust access model as needed generateClass(file('code.template'), access, "DB", packageName, basedir) } }
  • 38. Level Up Your Android Build - droidcon Berlin 2015 Advanced - Sqlite Access code.template package $packageName; public final class $className { public static final class Tables { <% access.tables.each { dataSet -> %> public static final String $dataSet.name = "$dataSet.sqlName"; <% } %> } ... }
  • 39. Level Up Your Android Build - droidcon Berlin 2015 Advanced - Groovy on Android buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.1.0' classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.6' } } apply plugin: 'groovyx.grooid.groovy-android' dependencies { compile 'org.codehaus.groovy:groovy:2.4.3:grooid' }
  • 40. Level Up Your Android Build - droidcon Berlin 2015 Resources (in order of appearance) Android plugin for Gradle https://developer.android.com/tools/building/plugin-for-gradle.html gdub Tool https://github.com/dougborg/gdub apt Plugin https://bitbucket.org/hvisser/android-apt Command Plugin https://github.com/novoda/gradle-android-command-plugin Gradle Plugin Portal http://plugins.gradle.org
  • 41. Level Up Your Android Build - droidcon Berlin 2015 Resources (in order of appearance) Proguard Annotation Squadleader https://bitbucket.org/littlerobots/squadleader Proguard Snippets https://github.com/krschultz/android-proguard-snippets Gradle Udacity Course https://www.udacity.com/wiki/ud867 Groovy library for git https://github.com/ajoberstar/grgit
  • 42. Level Up Your Android Build - droidcon Berlin 2015 Resources (in order of appearance) Soter Plugin https://github.com/dlabs/soter Shrink Guava Script Snippet https://gist.github.com/devisnik/e54ea0a629adc82bcfa0 Groovy Android Plugin https://github.com/groovy/groovy-android-gradle-plugin Sqlite Analyzer Plugin https://github.com/novoda/sqlite-analyzer
  • 43. Level Up Your Android Build - droidcon Berlin 2015 TDTD - Tester-Driven Talk Development Thanks to the folks from Android Stammtisch Berlin for serving as Testers for a lot of the presented material. Upcoming book: Growing Subject-Oriented Talks, Guided by Testers
  • 44. Level Up Your Android Build - droidcon Berlin 2015 Friedger Müffke Volker Leck fmdroid devisnik +FriedgerMüffke +VolkerLeck friedger devisnik
  • 45. Level Up Your Android Build - droidcon Berlin 2015 Build tooling
  • 46. Level Up Your Android Build - droidcon Berlin 2015 Problems ● no re-use outside android app ● limited and manual code quality assurance (via test feedback) ● limited automation ○ manual versioning ○ manual deployment ○ no continuous integration ○ tedious distribution (beta channels, bug tracking, ..) ○ dependent on Android SDK installation
  • 47. Level Up Your Android Build - droidcon Berlin 2015 Separation - Test Execution test { useJUnit { excludeCategories 'com.sample.api.LiveTest' } } task endpointTest(type: Test, dependsOn: testClasses) { useJUnit { includeCategories 'com.sample.api.LiveTest' } } annotate tests with: @Category(LiveTest.class)