SlideShare uma empresa Scribd logo
1 de 38
Baixar para ler offline
Tips for better CI on
Android
Tomoaki Imai @Potatotips #22 2015/10/13
Hi I’m Tomo(今井智章)
Hi I’m Tomo(今井智章)
Hi I’m Tomo(今井智章)
Hi I’m Tomo(今井智章)
Hi I’m Tomo(今井智章)
Continuous Integration
on Android
1. How do we CI on Android
2. 4 tips for better CI
1. How do we CI on Android
2. 4 tips for better CI
How do we CI Mercari
Android App?
CI for Mercari Android App
• Started April 2015
• Purpose
- Build Check each
Flavour and BuildType
- Automate app tests
- Continuous deployment
Phase 1: Travis CI
Good!!
• Easy setup with yml
• Build production app without
including secret keys into the
repo(http://docs.travis-ci.com/user/encrypting-
files/)
• Most of Mercari project
run CI on Travis CI
So-so…
• Need some tweaks to avoid Out of Memory
• Slow. Takes 12-15min/per build check
Phase 2: circleCI
Good!!
• Has better features for testing and debugging
• Bit faster than Travis CI (1- 2min for each build)
• Mercari iOS project runs CI on CircleCI
So-so…
• Need some tweaks to avoid Out of Memory
• Building production app looked a bit tricky
(Haven’t tried yet)
Both CI service have good
parts…
Why not use both?
Phase 3: Travis CI & circleCI
Check Production App
Check Development App
Run JUnit Tests
Deploy
Let each CI service do different tasks
Total CI Running time reduced
to 8-7 min(about 2x shorter)
1. How do we CI on Android
2. 4 tips for better CI
Tip 1: Avoid OOM(CircleCI)
• 4GB memory limit
Tip 1: Avoid OOM(CircleCI)
• 4GB memory limit
Tip 1: Avoid OOM(CircleCI)
https://circleci.com/docs/oom
but was in vain…
Guide for 4GB limit
Check memory_usage.txt
PID RSS %CPU COMMAND
21787 2250024 165 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Xmx4g -
Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /usr/
local/android-sdk-linux/build-tools/21.1.1/lib/dx.jar com.android.dx.command.Main --
dex --force-jumbo --output /home/ubuntu/mercari-android-as/app/build/intermediates/
dex/us/dev /home/ubuntu/mercari-android-as/app/build/intermediates/classes-proguard/
us/dev/classes.jar
9477 1628300 104 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -XX:
+HeapDumpOnOutOfMemoryError -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US -
Duser.language=en -Duser.variant -cp /home/ubuntu/.gradle/wrapper/dists/gradle-2.2.1-
all/6dibv5rcnnqlfbq9klf8imrndn/gradle-2.2.1/lib/gradle-launcher-2.2.1.jar
org.gradle.launcher.daemon.bootstrap.GradleDaemon 2.2.1 /home/ubuntu/.gradle/daemon
10800000 b3531fa1-fad3-4599-a284-96a81cc9336b -XX:+HeapDumpOnOutOfMemoryError -
Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant
9145 279164 4.7 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Xms256m -Xmx512m -
Dorg.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -
Dorg.gradle.appname=gradlew -classpath /home/ubuntu/mercari-android-as/gradle/wrapper/
gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain assembleDev -PdisablePreDex
Tip 1: Avoid OOM(CircleCI)
PID RSS %CPU COMMAND
21787 2250024 165 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Xmx4g -
Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /usr/
local/android-sdk-linux/build-tools/21.1.1/lib/dx.jar com.android.dx.command.Main --
dex --force-jumbo --output /home/ubuntu/mercari-android-as/app/build/intermediates/
dex/us/dev /home/ubuntu/mercari-android-as/app/build/intermediates/classes-proguard/
us/dev/classes.jar
9477 1628300 104 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -XX:
+HeapDumpOnOutOfMemoryError -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US -
Duser.language=en -Duser.variant -cp /home/ubuntu/.gradle/wrapper/dists/gradle-2.2.1-
all/6dibv5rcnnqlfbq9klf8imrndn/gradle-2.2.1/lib/gradle-launcher-2.2.1.jar
org.gradle.launcher.daemon.bootstrap.GradleDaemon 2.2.1 /home/ubuntu/.gradle/daemon
10800000 b3531fa1-fad3-4599-a284-96a81cc9336b -XX:+HeapDumpOnOutOfMemoryError -
Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant
9145 279164 4.7 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Xms256m -Xmx512m -
Dorg.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -
Dorg.gradle.appname=gradlew -classpath /home/ubuntu/mercari-android-as/gradle/wrapper/
gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain assembleDev -PdisablePreDex
Tip 1: Avoid OOM(CircleCI)
JVM is using too much memory!
2250024 + 1628300 + 279164 = 4157488KB ≒4GB
PID RSS %CPU COMMAND
21787 2250024 165 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Xmx4g -
Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /usr/
local/android-sdk-linux/build-tools/21.1.1/lib/dx.jar com.android.dx.command.Main --
dex --force-jumbo --output /home/ubuntu/mercari-android-as/app/build/intermediates/
dex/us/dev /home/ubuntu/mercari-android-as/app/build/intermediates/classes-proguard/
us/dev/classes.jar
9477 1628300 104 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -XX:
+HeapDumpOnOutOfMemoryError -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US -
Duser.language=en -Duser.variant -cp /home/ubuntu/.gradle/wrapper/dists/gradle-2.2.1-
all/6dibv5rcnnqlfbq9klf8imrndn/gradle-2.2.1/lib/gradle-launcher-2.2.1.jar
org.gradle.launcher.daemon.bootstrap.GradleDaemon 2.2.1 /home/ubuntu/.gradle/daemon
10800000 b3531fa1-fad3-4599-a284-96a81cc9336b -XX:+HeapDumpOnOutOfMemoryError -
Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant
9145 279164 4.7 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Xms256m -Xmx512m -
Dorg.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -
Dorg.gradle.appname=gradlew -classpath /home/ubuntu/mercari-android-as/gradle/wrapper/
gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain assembleDev -PdisablePreDex
Tip 1: Avoid OOM(CircleCI)
Progard + Gradle consumes memory a lot
Tip 1: Avoid OOM(CircleCI)
Tuning tips:
• Lower the total memory(JVM,Gradle) size to 4.0G
• Adjust Xmx and MaxPermSize
• Set timeout (>1000) for GC
Xmx -> Heap space (where object resources are allocated )
MaxPermSize -> Permgen(where class, methods are loaded)
Tip 1: Avoid OOM(CircleCI)
machine:

environment:

ANDROID_HOME: /usr/local/android-sdk-linux

_JAVA_OPTIONS: "-Xms256m -Xmx1280m -XX:MaxPermSize=350m"

GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx1536m -
XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError"'
…
override:

- ./gradlew assembleDev -PdisablePreDex:

timeout: 1500
Heap Perm Heap Perm other
JVM(dex) Gradle
4GB
• There is no best practice but I suggest that
large memory be allocated to Xmx
Tip 2: Save the JUnit test result(CircleCI)
test:

post:

- mkdir -p $CIRCLE_TEST_REPORTS/junit/

- find . -type f -regex ".*/test-results/*/.*xml" -exec cp {}
$CIRCLE_TEST_REPORTS/junit/ ;
• You can check Test result from ‘Test Failure’
http://qiita.com/tomoima525/items/b4a91d1624aaf0112b3f
Ref. CircleCIでJUnitの結果を見る
Tip 3: Continuous deployment for specific
branches(CircleCI)
• Run shell script for specific branches
deployment:

jp:

branch: [/deploy_jp_.*/, /release_.*/]

commands:

- ./deploy_jp.sh $CIRCLE_BRANCH

us:

branch: [/deploy_us_.*/, /release_.*/]

commands:

- ./deploy_us.sh $CIRCLE_BRANCH
RELEASE_MESSAGE=$1
#deploy

curl -F "file=@app/apk/mercari_dev_jp.apk" -F "token=$
{DEPLOY_GATE_API_KEY}" -F "message=${RELEASE_MESSAGE}" -F
"distribution_key=${JP_DEV_DIST_KEY}" -F "release_note=$
{RELEASE_MESSAGE}" https://deploygate.com/api/users/xxxx/apps
deploy_jp.sh
Tip 3: Continuous deployment for specific
branches(CircleCI)
• Set variables at `Environment variables`
Tip 4: Add dependencies manually
dependencies:
override:
- echo y | android update sdk --no-ui --all --filter extra-
google-m2repository,extra-android-m2repository,build-tools-23.0.1,
android-23
android:
components:
- build-tools-23.0.1
- android-23
- extra-android-m2repository
- extra-google-m2repository
.travis.yml
circle.yml
• The latest packages(ex. Android M) are not installed on
the VM
• Add manually with command line
• Tip 1: Check memory usage of JVM to
avoid OOM
• Tip 2: Save the JUnit test result on the VM
• Tip 3: Continuous deployment for specific
branches
• Tip 4: Add dependencies manually
Try it out for your project!

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

No more waiting for API - Android Stub Server
No more waiting for API - Android Stub ServerNo more waiting for API - Android Stub Server
No more waiting for API - Android Stub Server
 
Build Automation in Android
Build Automation in AndroidBuild Automation in Android
Build Automation in Android
 
WindowTester PRO
WindowTester PROWindowTester PRO
WindowTester PRO
 
DevOps 及 TDD 開發流程哲學
DevOps 及 TDD 開發流程哲學DevOps 及 TDD 開發流程哲學
DevOps 及 TDD 開發流程哲學
 
手機自動化測試和持續整合
手機自動化測試和持續整合手機自動化測試和持續整合
手機自動化測試和持續整合
 
No more video loss - Alex Rivkin, Motorola Solutions
No more video loss - Alex Rivkin, Motorola SolutionsNo more video loss - Alex Rivkin, Motorola Solutions
No more video loss - Alex Rivkin, Motorola Solutions
 
Trunk-Based Development
Trunk-Based DevelopmentTrunk-Based Development
Trunk-Based Development
 
Behat sauce
Behat sauceBehat sauce
Behat sauce
 
Vietnam qa meetup
Vietnam qa meetupVietnam qa meetup
Vietnam qa meetup
 
Effective Android Development. UA Mobile 2016.
Effective Android Development. UA Mobile 2016.Effective Android Development. UA Mobile 2016.
Effective Android Development. UA Mobile 2016.
 
Write microservice in golang
Write microservice in golangWrite microservice in golang
Write microservice in golang
 
Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!
Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!
Eclipse RCP outside of Eclipse IDE - Gradle to the rescue!
 
Getting started with docker
Getting started with dockerGetting started with docker
Getting started with docker
 
Fastlane on Android 介紹
Fastlane on Android 介紹Fastlane on Android 介紹
Fastlane on Android 介紹
 
Eclipse RCP Demo
Eclipse RCP DemoEclipse RCP Demo
Eclipse RCP Demo
 
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.
Критика "библиотечного" подхода в разработке под Android. UA Mobile 2016.
 
Eclipse Buildship JUG Hamburg
Eclipse Buildship JUG HamburgEclipse Buildship JUG Hamburg
Eclipse Buildship JUG Hamburg
 
Flutter Intro
Flutter IntroFlutter Intro
Flutter Intro
 
Continuous integration in games development
Continuous integration in games developmentContinuous integration in games development
Continuous integration in games development
 
iOS Automation with Cucumber, Appium and Saucelabs
iOS Automation with Cucumber, Appium and SaucelabsiOS Automation with Cucumber, Appium and Saucelabs
iOS Automation with Cucumber, Appium and Saucelabs
 

Destaque

Androidアプリ滞在時間の計測
Androidアプリ滞在時間の計測Androidアプリ滞在時間の計測
Androidアプリ滞在時間の計測
Shigeki Yamato
 

Destaque (20)

Introducing Cardio
Introducing CardioIntroducing Cardio
Introducing Cardio
 
Android development at mercari 2015
Android development at mercari 2015Android development at mercari 2015
Android development at mercari 2015
 
はじめての CircleCI
はじめての CircleCIはじめての CircleCI
はじめての CircleCI
 
US進出でのAndroid開発inメルカリ Mercari US App Development
US進出でのAndroid開発inメルカリ Mercari US App Development US進出でのAndroid開発inメルカリ Mercari US App Development
US進出でのAndroid開発inメルカリ Mercari US App Development
 
Debot android debugging library
Debot android debugging libraryDebot android debugging library
Debot android debugging library
 
MS Fest 2013: Vývoj her v C# a MonoGame pro WP, iOS a Android
MS Fest 2013: Vývoj her v C# a MonoGame pro WP, iOS a AndroidMS Fest 2013: Vývoj her v C# a MonoGame pro WP, iOS a Android
MS Fest 2013: Vývoj her v C# a MonoGame pro WP, iOS a Android
 
Bezpečnost platformy Android
Bezpečnost platformy AndroidBezpečnost platformy Android
Bezpečnost platformy Android
 
Kdyby/Events
Kdyby/EventsKdyby/Events
Kdyby/Events
 
What I learned about communication in Sanfrancisco
What I learned about communication in SanfranciscoWhat I learned about communication in Sanfrancisco
What I learned about communication in Sanfrancisco
 
CI in the mobile world
CI in the mobile worldCI in the mobile world
CI in the mobile world
 
Enterprise level cloud CI
Enterprise level cloud CIEnterprise level cloud CI
Enterprise level cloud CI
 
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみるCocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
Cocoa勉強会#62-新しい通信クラス群NSURLSessionを使ってみる
 
Androidアプリ滞在時間の計測
Androidアプリ滞在時間の計測Androidアプリ滞在時間の計測
Androidアプリ滞在時間の計測
 
Material Designなdrawerを実装したい
Material Designなdrawerを実装したいMaterial Designなdrawerを実装したい
Material Designなdrawerを実装したい
 
Ci tools Introduce
Ci tools IntroduceCi tools Introduce
Ci tools Introduce
 
Fast deterministic screenshot tests for Android
Fast deterministic screenshot tests for AndroidFast deterministic screenshot tests for Android
Fast deterministic screenshot tests for Android
 
Developing better debug_components
Developing better debug_componentsDeveloping better debug_components
Developing better debug_components
 
Core Principles Of Ci
Core Principles Of CiCore Principles Of Ci
Core Principles Of Ci
 
What makes Geb groovy?
What makes Geb groovy?What makes Geb groovy?
What makes Geb groovy?
 
ハンドメイドカレンダー第15回potatotips用
ハンドメイドカレンダー第15回potatotips用ハンドメイドカレンダー第15回potatotips用
ハンドメイドカレンダー第15回potatotips用
 

Semelhante a Tips for better CI on Android

Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Docker, Inc.
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
Kan-Ru Chen
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Opersys inc.
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
Opersys inc.
 

Semelhante a Tips for better CI on Android (20)

Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013Lightweight Virtualization with Linux Containers and Docker | YaC 2013
Lightweight Virtualization with Linux Containers and Docker | YaC 2013
 
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013Lightweight Virtualization with Linux Containers and Docker I YaC 2013
Lightweight Virtualization with Linux Containers and Docker I YaC 2013
 
Android Boot Time Optimization
Android Boot Time OptimizationAndroid Boot Time Optimization
Android Boot Time Optimization
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned  Real-World Docker: 10 Things We've Learned
Real-World Docker: 10 Things We've Learned
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Digging for Android Kernel Bugs
Digging for Android Kernel BugsDigging for Android Kernel Bugs
Digging for Android Kernel Bugs
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android for Embedded Linux Developers
Android for Embedded Linux DevelopersAndroid for Embedded Linux Developers
Android for Embedded Linux Developers
 
Containers from Scratch: what are they made from?
Containers from Scratch: what are they made from?Containers from Scratch: what are they made from?
Containers from Scratch: what are they made from?
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Perspectives on Docker
Perspectives on DockerPerspectives on Docker
Perspectives on Docker
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Us 17-krug-hacking-severless-runtimes
Us 17-krug-hacking-severless-runtimesUs 17-krug-hacking-severless-runtimes
Us 17-krug-hacking-severless-runtimes
 
ContainerCon sysdig Slides
ContainerCon sysdig Slides ContainerCon sysdig Slides
ContainerCon sysdig Slides
 
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
Native Android Userspace part of the Embedded Android Workshop at Linaro Conn...
 
Android Platform Debugging and Development
Android Platform Debugging and DevelopmentAndroid Platform Debugging and Development
Android Platform Debugging and Development
 
Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013Working with the AOSP - Linaro Connect Asia 2013
Working with the AOSP - Linaro Connect Asia 2013
 

Último

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 

Último (20)

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban%in Durban+277-882-255-28 abortion pills for sale in Durban
%in Durban+277-882-255-28 abortion pills for sale in Durban
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 

Tips for better CI on Android

  • 1. Tips for better CI on Android Tomoaki Imai @Potatotips #22 2015/10/13
  • 8. 1. How do we CI on Android 2. 4 tips for better CI
  • 9. 1. How do we CI on Android 2. 4 tips for better CI
  • 10. How do we CI Mercari Android App?
  • 11. CI for Mercari Android App • Started April 2015 • Purpose - Build Check each Flavour and BuildType - Automate app tests - Continuous deployment
  • 13. Good!! • Easy setup with yml • Build production app without including secret keys into the repo(http://docs.travis-ci.com/user/encrypting- files/) • Most of Mercari project run CI on Travis CI
  • 14. So-so… • Need some tweaks to avoid Out of Memory • Slow. Takes 12-15min/per build check
  • 16. Good!! • Has better features for testing and debugging • Bit faster than Travis CI (1- 2min for each build) • Mercari iOS project runs CI on CircleCI
  • 17. So-so… • Need some tweaks to avoid Out of Memory • Building production app looked a bit tricky (Haven’t tried yet)
  • 18. Both CI service have good parts…
  • 19. Why not use both?
  • 20. Phase 3: Travis CI & circleCI
  • 21. Check Production App Check Development App Run JUnit Tests Deploy Let each CI service do different tasks
  • 22. Total CI Running time reduced to 8-7 min(about 2x shorter)
  • 23. 1. How do we CI on Android 2. 4 tips for better CI
  • 24. Tip 1: Avoid OOM(CircleCI) • 4GB memory limit
  • 25. Tip 1: Avoid OOM(CircleCI) • 4GB memory limit
  • 26. Tip 1: Avoid OOM(CircleCI) https://circleci.com/docs/oom but was in vain… Guide for 4GB limit
  • 28. PID RSS %CPU COMMAND 21787 2250024 165 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Xmx4g - Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /usr/ local/android-sdk-linux/build-tools/21.1.1/lib/dx.jar com.android.dx.command.Main -- dex --force-jumbo --output /home/ubuntu/mercari-android-as/app/build/intermediates/ dex/us/dev /home/ubuntu/mercari-android-as/app/build/intermediates/classes-proguard/ us/dev/classes.jar 9477 1628300 104 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -XX: +HeapDumpOnOutOfMemoryError -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US - Duser.language=en -Duser.variant -cp /home/ubuntu/.gradle/wrapper/dists/gradle-2.2.1- all/6dibv5rcnnqlfbq9klf8imrndn/gradle-2.2.1/lib/gradle-launcher-2.2.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 2.2.1 /home/ubuntu/.gradle/daemon 10800000 b3531fa1-fad3-4599-a284-96a81cc9336b -XX:+HeapDumpOnOutOfMemoryError - Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant 9145 279164 4.7 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Xms256m -Xmx512m - Dorg.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError - Dorg.gradle.appname=gradlew -classpath /home/ubuntu/mercari-android-as/gradle/wrapper/ gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain assembleDev -PdisablePreDex Tip 1: Avoid OOM(CircleCI)
  • 29. PID RSS %CPU COMMAND 21787 2250024 165 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Xmx4g - Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /usr/ local/android-sdk-linux/build-tools/21.1.1/lib/dx.jar com.android.dx.command.Main -- dex --force-jumbo --output /home/ubuntu/mercari-android-as/app/build/intermediates/ dex/us/dev /home/ubuntu/mercari-android-as/app/build/intermediates/classes-proguard/ us/dev/classes.jar 9477 1628300 104 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -XX: +HeapDumpOnOutOfMemoryError -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US - Duser.language=en -Duser.variant -cp /home/ubuntu/.gradle/wrapper/dists/gradle-2.2.1- all/6dibv5rcnnqlfbq9klf8imrndn/gradle-2.2.1/lib/gradle-launcher-2.2.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 2.2.1 /home/ubuntu/.gradle/daemon 10800000 b3531fa1-fad3-4599-a284-96a81cc9336b -XX:+HeapDumpOnOutOfMemoryError - Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant 9145 279164 4.7 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Xms256m -Xmx512m - Dorg.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError - Dorg.gradle.appname=gradlew -classpath /home/ubuntu/mercari-android-as/gradle/wrapper/ gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain assembleDev -PdisablePreDex Tip 1: Avoid OOM(CircleCI) JVM is using too much memory! 2250024 + 1628300 + 279164 = 4157488KB ≒4GB
  • 30. PID RSS %CPU COMMAND 21787 2250024 165 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Xmx4g - Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant -cp /usr/ local/android-sdk-linux/build-tools/21.1.1/lib/dx.jar com.android.dx.command.Main -- dex --force-jumbo --output /home/ubuntu/mercari-android-as/app/build/intermediates/ dex/us/dev /home/ubuntu/mercari-android-as/app/build/intermediates/classes-proguard/ us/dev/classes.jar 9477 1628300 104 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -XX: +HeapDumpOnOutOfMemoryError -Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US - Duser.language=en -Duser.variant -cp /home/ubuntu/.gradle/wrapper/dists/gradle-2.2.1- all/6dibv5rcnnqlfbq9klf8imrndn/gradle-2.2.1/lib/gradle-launcher-2.2.1.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 2.2.1 /home/ubuntu/.gradle/daemon 10800000 b3531fa1-fad3-4599-a284-96a81cc9336b -XX:+HeapDumpOnOutOfMemoryError - Xmx2048m -Dfile.encoding=UTF-8 -Duser.country=US -Duser.language=en -Duser.variant 9145 279164 4.7 /usr/lib/jvm/java-7-openjdk-amd64/bin/java -Xms256m -Xmx512m - Dorg.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError - Dorg.gradle.appname=gradlew -classpath /home/ubuntu/mercari-android-as/gradle/wrapper/ gradle-wrapper.jar org.gradle.wrapper.GradleWrapperMain assembleDev -PdisablePreDex Tip 1: Avoid OOM(CircleCI) Progard + Gradle consumes memory a lot
  • 31. Tip 1: Avoid OOM(CircleCI) Tuning tips: • Lower the total memory(JVM,Gradle) size to 4.0G • Adjust Xmx and MaxPermSize • Set timeout (>1000) for GC Xmx -> Heap space (where object resources are allocated ) MaxPermSize -> Permgen(where class, methods are loaded)
  • 32. Tip 1: Avoid OOM(CircleCI) machine:
 environment:
 ANDROID_HOME: /usr/local/android-sdk-linux
 _JAVA_OPTIONS: "-Xms256m -Xmx1280m -XX:MaxPermSize=350m"
 GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx1536m - XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError"' … override:
 - ./gradlew assembleDev -PdisablePreDex:
 timeout: 1500 Heap Perm Heap Perm other JVM(dex) Gradle 4GB • There is no best practice but I suggest that large memory be allocated to Xmx
  • 33. Tip 2: Save the JUnit test result(CircleCI) test:
 post:
 - mkdir -p $CIRCLE_TEST_REPORTS/junit/
 - find . -type f -regex ".*/test-results/*/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ ; • You can check Test result from ‘Test Failure’ http://qiita.com/tomoima525/items/b4a91d1624aaf0112b3f Ref. CircleCIでJUnitの結果を見る
  • 34. Tip 3: Continuous deployment for specific branches(CircleCI) • Run shell script for specific branches deployment:
 jp:
 branch: [/deploy_jp_.*/, /release_.*/]
 commands:
 - ./deploy_jp.sh $CIRCLE_BRANCH
 us:
 branch: [/deploy_us_.*/, /release_.*/]
 commands:
 - ./deploy_us.sh $CIRCLE_BRANCH RELEASE_MESSAGE=$1 #deploy
 curl -F "file=@app/apk/mercari_dev_jp.apk" -F "token=$ {DEPLOY_GATE_API_KEY}" -F "message=${RELEASE_MESSAGE}" -F "distribution_key=${JP_DEV_DIST_KEY}" -F "release_note=$ {RELEASE_MESSAGE}" https://deploygate.com/api/users/xxxx/apps deploy_jp.sh
  • 35. Tip 3: Continuous deployment for specific branches(CircleCI) • Set variables at `Environment variables`
  • 36. Tip 4: Add dependencies manually dependencies: override: - echo y | android update sdk --no-ui --all --filter extra- google-m2repository,extra-android-m2repository,build-tools-23.0.1, android-23 android: components: - build-tools-23.0.1 - android-23 - extra-android-m2repository - extra-google-m2repository .travis.yml circle.yml • The latest packages(ex. Android M) are not installed on the VM • Add manually with command line
  • 37. • Tip 1: Check memory usage of JVM to avoid OOM • Tip 2: Save the JUnit test result on the VM • Tip 3: Continuous deployment for specific branches • Tip 4: Add dependencies manually
  • 38. Try it out for your project!