Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Androidアプリケーションのビルド体験をリモートインスタンスで改善する

yagi
February 01, 2017

 Androidアプリケーションのビルド体験をリモートインスタンスで改善する

Enjoy Android Application Development !

yagi

February 01, 2017
Tweet

More Decks by yagi

Other Decks in Technology

Transcript

  1. "OESPJEΞϓϦέʔγϣϯ
    ͷϏϧυମݧΛϦϞʔτΠϯ
    ελϯεͰվળ͢Δ
    2017/02/01
    ୈ2ճελʔτΞοϓAndroidษڧձ
    Toshihiro Yagi

    View full-size slide

  2. ࣗݾ঺հ
    w 5PTIJIJSP:BHJ !TZTZBHJ

    w DPPLQBE
    w "OESPJEΤϯδχΞ ٕज़෦௕

    View full-size slide

  3. "OESPJEΞϓϦέʔγϣϯ
    ͷϏϧυͷ՝୊
    w Ϗϧυʹ͕͔͔࣌ؒΔ
    w ϏϧυΛ଴ͭؒ$16΍ϝϞϦΛઐ༗
    ͞Εͯ͠·ͬͯଞͷ࡞ۀ͕Ͱ͖ͳ͍

    View full-size slide

  4. "OESPJEΞϓϦέʔγϣϯ
    ͷϏϧυͷ՝୊
    w Ϗϧυʹ͕͔͔࣌ؒΔ
    w ϏϧυΛ଴ͭؒ$16΍ϝϞϦΛઐ༗
    ͞Εͯ͠·ͬͯଞͷ࡞ۀ͕Ͱ͖ͳ͍

    View full-size slide

  5. ରࡦ
    w CVJMEHSBEMFΛνϡʔχϯά
    w *OTUBOU3VOΛ࢖͏
    w ϋΠεϖοΫϚγϯΛௐୡ

    View full-size slide

  6. ରࡦ
    w CVJMEHSBEMFΛνϡʔχϯά
    w *OTUBOU3VOΛ࢖͏
    w ϋΠεϖοΫϚγϯΛௐୡ
    w ϦϞʔτϏϧυΛ࢖͏OFX

    View full-size slide

  7. ϦϞʔτϏϧυͷงғؾ
    Local
    Machine
    ᶃ sync code Remote Machine
    ᶄ build
    ᶅ get apk
    ᶆ install apk & launch activity
    Ϗϧυͷ෦෼ΛϦϞʔτϚγϯʹҕৡ͢Δ͜ͱͰ
    ϩʔΧϧϚγϯͷϦιʔεΛઐ༗͠ͳ͍

    View full-size slide

  8. ϦϞʔτϏϧυͷར఺
    w ϩʔΧϧϚγϯͷϦιʔεΛѹഭ͠ͳ͍
    w ෳ਺ͷϚγϯ͔Β࢖͑Δ؀ڥΛͭ͘ΕΔ
    w ϦϞʔτϚγϯͷεϖοΫ࣍ୈͰύϑΥʔ
    Ϛϯε͸ແݶେ
    w Ϋϥ΢υΛ࢖͏৔߹
    ࣗ༝ʹࣺͯΒΕΔ

    View full-size slide

  9. ϦϞʔτϏϧυ؀ڥߏஙखॱ
    w ϦϞʔτϚγϯΛ༻ҙ͢Δ
    w ϦϞʔτϚγϯͷ؀ڥΛ࡞Δ
    w ϦϞʔτϏϧυ༻ͷεΫϦϓτΛ༻ҙ͢Δ
    w ࢖͏ɻշదɻ࠷ߴ?P?
    w ίετͱ޻෉

    View full-size slide

  10. ϦϞʔτϚγϯΛ༻ҙ͢Δ
    w ༨ͬͨϚγϯ
    w ϦϞʔτΠϯελϯε ($1 "84 "[VSFʜ

    View full-size slide

  11. ϦϞʔτϚγϯΛ༻ҙ͢Δ
    w ༨ͬͨϚγϯ
    w ϦϞʔτΠϯελϯε ($1 "84 "[VSFʜ

    View full-size slide

  12. ϦϞʔτϚγϯͷ؀ڥΛ࡞Δ
    w "84 ($1ͳͲͰΠϯελϯεΛ࡞Δ
    w ϦϞʔτϚγϯͷ੩త*1Λઃఆ͢Δ
    w BOESPJEͷϏϧυ؀ڥΛߏங͢Δ
    w ϩʔΧϧϚγϯͰTTILFZΛൃߦͯ͠ొ࿥͢Δ

    View full-size slide

  13. ϦϞʔτϚγϯͷ؀ڥΛ࡞Δ
    http://sys1yagi.hatenablog.com/entry/2016/11/13/162400

    View full-size slide

  14. ϦϞʔτϏϧυ༻ͷ
    εΫϦϓτΛ༻ҙ͢Δ
    GBCSJDΛ࢖ͬͨྫ
    @task
    def build():
    build_dir = tmp_dir + package
    sync(build_dir)
    gradle_cmd = assemble_command()
    apk_name = apk_name_format()
    # run gradlew on remote instance
    with cd(build_dir):
    run(gradle_cmd)
    # get apk
    local("mkdir -p " + module + "/build/outputs/apk/")
    get(remote_path=build_dir + "/" + module + "/build/outputs/apk/" + apk_name,
    local_path=module + "/build/outputs/apk/")
    # start App
    local("adb" + " push ./" + module + "/build/outputs/apk/" + apk_name + " /data/local/tmp/" + package)
    local("adb" + " shell pm install -r '/data/local/tmp/" + package + "'")
    local("adb" + " shell am start -n '" + package + "/" + launch_activity + "' -a android.intent.action.MAIN -c android.intent.category.LAUNCHER")

    View full-size slide

  15. ࢖͏ɻշదɻ࠷ߴ?P?

    View full-size slide

  16. ίετͱ޻෉
    w େମշదͳεϖοΫ
    w ($1OIJHIDQV ถࠃ
    I
    w "84DYMBSHF ౦ژ
    I
    w ͣͬͱىಈͬ͠ͺͳ͠ͷ৔߹ֹ݄
    w ($1
    w "84

    View full-size slide

  17. ࣗಈγϟοτμ΢ϯ
    w $MPVE8BUDIΛ࢖ͬͨࣗಈγϟοτμ΢ϯ "84

    w ͖͍͠஋Λz࣌ؒʹର͢Δ$166UJMJ[BUJPO
    $166UJMJ[BUJPO
    zͰઃఆ
    w ΞΫγϣϯͱͯ͠γϟοτμ΢ϯΛઃఆ
    w ىಈ͸GBCSJDͰCPUPΛ࢖ͬͯϏϧυ࣌ʹ௚઀"1*
    Λୟ͘
    w ($1͸DSPO࢓ࠐΉͱ͔ʹͳΓͦ͏ɻHDMPVEͰىಈ

    View full-size slide

  18. ϲ݄ͷར༻࣌ؒͱίετ
    w ΤϯδχΞ໊
    w ߹ܭར༻࣌ؒd࣌ؒ
    w ֹ݄d
    w Ұਓ͋ͨΓd

    View full-size slide

  19. ମݧ͕͍͍͘͢͝ͷͰੋඇ͓ࢼ͍ͩ͘͠͞ɻ

    View full-size slide

  20. ͱΓ͋͑ͣؾܰʹࢼͯ͠Έ͍ͨͱ
    ͍͏࣌͸

    View full-size slide

  21. $ZCPSH#VJME
    http://cyborg-build.com/

    View full-size slide

  22. $ZCPSH#VJMEͷ࢓૊Έ
    Local
    Machine
    GCS
    Bucket
    Cyborg-Build.com
    Remote Instance
    ᶃrsync code
    ᶄbuild request
    ᶅremote op
    ᶆrsync code
    ᶇbuild on docker
    ᶈupload artefacts
    ᶉdownload artefacts
    ᶊinstall & launch
    ϩάΠϯͨ͠(PPHMFΞΧ΢ϯτͱDZCPSHCVJMEDPNͷΈ͕ιʔείʔυʹ৮ΕΔߏ଄

    View full-size slide

  23. "MQIB1SFWJFX
    w ࠓͷͱ͜Ζແྉ
    w HDMPVEGBCSJDͰར༻Մೳ
    w CVJMEMBVODIͷ΄͔UFTU΍MJOU݁Ռͷอଘͳ
    Ͳ΋αϙʔτ
    w *%&"QMVHJOԽ༧ఆ
    w ͥͻ͓ࢼ͍ͩ͘͠͞ϑΟʔυόοΫ͍ͩ͘͞

    View full-size slide

  24. &OKPZ
    "OESPJE"QQMJDBUJPO
    %FWFMPQNFOU

    View full-size slide