Android Continuous Integration And Deployment
About me
Presentation
- Why Continuous integration
- Gradle setup
- Unit Test
- Automated test
- CircleCI
- Teamcity
- Deployment with Beta
- Deployment with Play Store
- What's next
Why?
- Automatic build
- Reduce integration problems
- Find bugs earlier
- Code versioning
- Code analysis
- Regression testing
- Monitor build speed and size
- Anyone can get a fresh build
- Automatic deployment
Gradle and Flavors
- Product Flavors
- Build types
Build types
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable true
applicationIdSuffix ".debug"
signingConfig signingConfigs.debug
}
Flavor types
dev {
dimension "api"
minSdkVersion 24
versionCode 30000 + android.defaultConfig.versionCode
versionNameSuffix "-dev"
dimension "playstore"
applicationIdSuffix ".dev"
versionName "${productVersion}.${versionBuild}"
}
Gradle Example
Circle Ci
- Circle Ci and Github or BitBucket
- Circle Ci configuration
- Circle Ci secret storage
version: 2
jobs:
build:
working_directory: ~/code
docker:
- image: circleci/android:api-27
environment:
JVM_OPTS: -Xmx3200m
steps:
- checkout
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Run Tests
command: ./gradlew lintQaRelease testQaRelease
command: ./gradlew assembleQaRelease
command: ./gradlew crashlyticsUploadDistributionQaRelease
- store_artifacts:
path: app/build/reports
destination: reports
- store_test_results:
path: app/build/test-results
Circle Ci Ui
Circle Ci Ui
TeamCity by JetBrains
TeamCity
TeamCity
TeamCity
TeamCity
TeamCity
TeamCity
TeamCity
TeamCity
TeamCity
TeamCity
Testing
- Unit tests
- Automated tests
- JaCoCo reports
JaCoCo
build.gradle
apply plugin: "jacoco"
jacoco {
toolVersion = "0.8.1"
reportsDir = file("$buildDir/customJacocoReportDir")
}
app/build.gradle
jacocoTestReport {
reports {
xml.enabled false
csv.enabled false
html.destination file("${buildDir}/jacocoHtml")
}
}
jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = 0.5
}
}
}
}
Fabric Beta
Gradle Fabric plugin
app/build.gradle
apply plugin: "io.fabric"
dependencies {
implementation "com.crashlytics.sdk.android:crashlytics:2.9.1"
}
./gradlew crashlyticsUploadDistributionQaRelease
Fabric Beta
Gradle Fabric plugin
public class CustomApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
final Fabric fabric = new Fabric.Builder(this)
.kits(new Crashlytics())
.build();
Fabric.with(fabric);
}
}
Google Play Store
Gradle plugin
- Upload a first version of your apk on the web console
- Create Service Account
- Export json config
Google Play Store
Gradle plugin
app/build.gradle
playAccountConfigs {
defaultAccountConfig {
jsonFile = file('keys.json')
}
}
defaultConfig {
// ...
playAccountConfig = playAccountConfigs.defaultAccountConfig
}
Google Play Store
Gradle plugin
build.gradle
apply plugin: 'com.github.triplet.play'
app/build.gradle
buildscript {
dependencies {
classpath 'com.github.triplet.gradle:play-publisher:1.2.0'
}
}
./gradlew publishApkProdRelease
Some other CI
- TravisCi
- CodeShip
- Bitrise
- GitLab
- Buddy
- Bamboo
What's Next
Questions?
Android CI &CD
By michaelb85
Android CI &CD
Talk about CI and CD for Android
- 1,323