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

気になったセッションから今すぐ開発に導入したいあれこれ(主観

Df866cf39671a846639b2d2011b1dca8?s=47 kobashin
November 07, 2019

 気になったセッションから今すぐ開発に導入したいあれこれ(主観

Df866cf39671a846639b2d2011b1dca8?s=128

kobashin

November 07, 2019
Tweet

Transcript

  1. Android Dev Summit2019ใࠂձ ؾʹͳͬͨηογϣϯ͔Βɺ ࠓ͙͢ϓϩμΫτ։ൃʹಋೖ͍ͨ͋͠Ε͜Ε @kobashinG ʢ͜͹͠Μʣ 2019.11.07

  2. ࣗݾ঺հ ͜͹͠Μ (@kobashinG) ๭ࣾͰECαʔϏε (AndroidΞϓϦ୲౰)΍ͬͯ·͢ ϑϩϯτΤϯυશൠ, etc… Android, Linux, k8s,

  3. ࠓ೔ͷ͓඼ॻ͖ • ࢹௌͨ͠ηογϣϯ • VitalsΛΧελϚΠζ͍ͯ͜͠͏ • ProfilerͰϝϞϦϦʔΫͱରቂ͢Δ • JetpackҠߦ͸͓ࡁΈͰ͔͢ʁ •

    ͍ͬͺ͍͓࿩͍ͨ͠ͷͰɺͦͷଞ͸௚઀͓࿩͠·͠ΐ
  4. ࠓ೔ͷࢿྉ͸ͪ͜Βʹࣄલެ։͍ͯ͠·͢ ⬇ http://ow.ly/kUmN50x4vv9

  5. ࢹௌͨ͠ηογϣϯ • Keynote • What’s New in Android Studio •

    LiveData with Coroutine Flow • Fragments Past / Future • Androidx Webkit • Going Edge to Edge with Gesture Navigation • Supercharge Sharing to your App • Migrate to Androidx: The time is right • Debugging Tips and n’Tricks • Performance Myth Busters • Demystify the Data 
 in Android Studio Profilers • Monitoring and Improving 
 Real-World Stability and Performance • Fragments Past / Future • Performance Analysis Using Systrace
  6. Some Topics

  7. ࠓ͙͢ϓϩμΫτʹ͍Ε͍ͨػೳͨͪ • Edge to Edge navigationͷNavigation Conflict

  8. ࠓ͙͢ϓϩμΫτʹ͍Ε͍ͨػೳͨͪ • Share SheetΛ֦ு͢Δʂ

  9. ࠓ͙͢ϓϩμΫτʹ͍Ε͍ͨػೳͨͪ • Fragment Factory

  10. Monitoring and Improving 
 Real-World Stability and Performance Android Vitals׆༻ͯ͠·͔͢ʁ

    https://youtu.be/mXzy0NX9bSM
  11. Android Vitalsʁ • ΞϓϦͷ҆ఆੑɾύϑΥʔϚϯ εΛ޲্͢ΔͨΊͷࢦඪΛఏڙ ͯ͘͠ΕΔ

  12. Core Vitals • ϢʔβʔମݧʹӨڹ͠΍͍͢ࢦඪΛՄࢹԽ • ಛʹॏཁͳࢦඪ͸ • Crash Rate •

    ANR Rate • Battery • Wakelock / Wakeup
  13. Core Vitals • ڐ༰Ͱ͖Δ͖͍͠஋Λઃఆͯ͘͠Ε͍ͯΔ • Core Vitalsͷ஋͸Play Store಺ͷݕࡧείΞ౳ʹӨڹ͢Δ

  14. Crash Rate ղੳʹศརͳϑΟϧλ͕༻ ҙ͞ΕͯΔ ྨࣅΞϓϦͱͷൺֱ

  15. Crash Rate ΞϓϦ໊΍ొ࿥৘ใ͔ΒࣗಈͰྨࣅ ΞϓϦΛબΜͰ͘Ε͍ͯΔɻ ଟগζϨ͍ͯΔ͜ͱ΋͋ΔͷͰɺ νϡʔχϯά͓͖ͯ͠·͠ΐ͏

  16. Core Vitals ৴པ۠ؒΛදࣔ͢ΔͱΏ Ε΋֬ೝͰ͖Δ ͍͔ͭΒ͖͍͠஋Λ௒͑ ͨͷ͔Λ֬ೝͰ͖Δ

  17. Core Vitals ͜ΕΒͰ֬ೝͰ͖Δ • ΞϓϦόʔδϣϯ • OSόʔδϣϯ • σόΠε

  18. Core Vitals ໰୊͕ൃੜ͍ͯ͠Ε͹ ௨஌ͯ͘͠ΕΔ ௨஌ઃఆ͢Ε͹ϝʔϧ ड৴΋Ͱ͖Δ

  19. Core Vitals • Crashৄࡉ͸Crashlyticsͱ΄΅ಉ͡ • Ϧετදࣔͷ࢓ํʢ·ͱ·Γํʣ͸ଟগҟͳΔ • ࠓͷϓϩδΣΫτͩͱேձͰோΊΔͷʹར༻
 ⇢σόοά࣌ʹ͸CrashlyticsΛར༻

  20. Core Vitals • ೉ಡԽΛ໭͢͜ͱ͕Ͱ͖ΔͷͰɺϦϦʔε࣌ʹ͸ mapping.txtΛ্͛๨Εͳ͍Α͏ʹ

  21. Pre-Launch Report • ΞϓϦέʔγϣϯͷϦϦʔεલϨϙʔ τΛ࡞੒Ͱ͖Δ • Vitalsͱҧ͍࣮؀ڥͰ͸ͳ͘ɺ੍ݶ͞ Εͨ؀ڥͷͨΊɺσόοάʹඞཁͳ৘ ใ͕ৄࡉʹऔΕΔ •

    10+ͷσόΠεͰςετ࣮ࢪ͞ΕΔ
  22. Pre-Launch Report • ͍͔ͭ͘ͷ࣠ຖʹςετ݁Ռ͕ݟΕΔ • όʔδϣϯ͝ͱͷਪҠͳͲ΋ՄࢹԽ͞ΕΔ • ςετ಺༰͕ΧελϚΠζ͕Ͱ͖Δʂ

  23. Pre-Launch Report ΧελϚΠζ • Firebase Test LabͷཁྖͰΧελϚΠζՄೳ • Robo Script͸ը໘Λૢ࡞͢Δ͚ͩͰ࡞੒Ͱ͖Δ

  24. None
  25. Pre-Launch Report ΧελϚΠζ • ೝূ৘ใΛ෇༩Ͱ͖ΔͷͰɺϩάΠϯՄೳ • ͨͩ͠ɺR.idࢦఆ͕ඞཁɻWebViewͰͷϩάΠϯ࣮૷ͷ৔߹͸NG

  26. Pre-Launch Report ΧελϚΠζ • 3ͭ·ͰDeeplinkΛઃఆՄೳ • Robo͸ࣗಈςετͳͷͰɺඞͣߦͬͯ΄͍͠Օ ॴΛࢦఆ͓ͯ͘͠ͱ͍͍ •

  27. Pre-Launch Report • ϦϦʔεલͷ࠷ऴνΣοΫͱ͔ͯ͠ͳΓΠέͯΔ • ੵۃతʹར༻͍͖͍͕ͯͨ͠ɺ͕͔͔࣌ؒΔ͜ͱ ΋͋ΔͷͰϦϦʔε௚લʹAPKΛ্͛Δ࣌͸஫ҙ

  28. ηογϣϯͰऔΓ্͛ΒΕ͍֤ͯͨࣾͷରԠࣄྫ • Migrated from background services to MediaBrows erService(API26) •

    Moved to WorkManager • Reduced use of Shared Preferences • Reorganized the app graph to perform less object i nstantiation in application's onCreate()
  29. Demystify the Data 
 in Android Studio Profilers ߴػೳͳ1SPGJMFS͕͍ͭͯ·͕͢ɺ ׆༻ͯ͠·͔͢ʁ

    https://youtu.be/v4kCRZ_O4Lc
  30. ProfilerΛ࢖ͬͯϝϞϦϦʔΫͱରቂ͢Δ • CPU / Memory / Network / EnergyͷࢦඪͰݟΕΔ •

    Memoryʹ Leaked Activities and Fragments ͕૿͑ ͯΔʢAS3.6ʣ
  31. Leaked Activities and Fragments ·ͣHeap DumpΛͱΔ ͜͜ʹग़ͯ͘Δ ϦʔΫͯ͠ΔActivity / Fragment

  32. ActivityͱFragmentͷϦʔΫͱ͸ʁ • Activity • Has been destroyed but is still

    referenced • Fragment • Does not have a valid FragmentManager 
 but is still referenced • Possible false positives • Created but has not yet been used • Being cached but not as part of a Fragmenttransaction
  33. Instance View • Depth • Native • Shallow • Retained

    Size
  34. Instance View ΦϒδΣΫτࣗ਎ͷαΠζ RootͷΦϒδΣΫτ͕ࢀর ͍ͯ͠ΔΦϒδΣΫτͷ࿨ NativeͷαΠζ • ྫ͑͹ɺ੺ͷΦϒδΣΫτ͕ফ͑ͯ΋ΦϨϯδʹ ଞ͔Βͷࢀর͕࢒͍ͬͯΔͱʁʁ

  35. Instance View

  36. • ϦʔΫ͍ͯ͠ΔΦϒ δΣΫτ΁ͷࢀরΛ ݟΕΔ • ͜͜Λݟͳ͕Βɺࢀ রΛফ͍ͯ͘͠ͱ͍ ͍ Reference View

  37. Կ͕ݪҼͩͬͨͷʁ • ࠓճͷݪҼ͸koinΛ࢖͍ͬͯͯɺಈతʹDIίϯςφʹೖΕͯ ͍ͨViewModelͷΠϯελϯε͔ΒͷFragment΁ͷࢀর͕ ࢒ͬͯ͠·͍ͬͯͨ • Reference Viewͷ͓͔͛ͰҰ໨ྎવͩͬͨͷͰɺ
 ͔ͳΓॿ͔Γ·ͨ͠

  38. • ηογϣϯͰ͸CPU Profilerͷ࢖͍ํ΋ৄࡉʹઆ໌͠ ͍ͯΔͷͰɺڵຯ͕͋Ε͹ͥͻݟ·͠ΐ͏

  39. Migrating to AndroidX:
 The time is right Jetpack / AndroidXʹҠߦ͸͓ࡁΈͰ͔͢ʁ

  40. Jetpack / AndroidX • I/O 2018ͰSupport Library Λ androidxͷnamespaceʹ
 Ҡ͢ൃද͕͞Εͨ

    • ͢ͰʹSupport Library͸28.0.xͰ։ൃ͕ࢭ·͍ͬͯΔ • όάϑΟοΫεɺ৽ػೳ͸AndroidXʹ • ੵۃతʹ࢖͍͖͍͚ͬͯͨͲɺҠߦ͕ɺɺ
  41. Migrating to AndroidX • ΄΅͢΂ͯͷϑΝΠϧʹมߋ͕ೖΔͷͰɺ
 ଞ࡞ۀͱฏߦͯ͢͢͠ΊΔͷ͸͓͢͢ΊͰ͖ͳ͍
 ⇢࡞ۀλΠϛϯάΛௐ੔͢Δ • Ұ൪࢝ΊʹɺϓϩδΣΫτΛόοΫΞοϓ͢Δ͜ͱ

  42. Migrating to AndroidX 1. Update to SL 28 AndroidX΁ͷҠߦ =ʮAPI

    ChangeʯʮPackage Changeʯ Support Library 28 <=> AndroidX 1.0ͷࠩ෼͸PackageͷΈ ·ͣ͸SL28΁ͷΞοϓσʔτΛߦ͍ɺ API changesʹΑͬͯյΕͳ͍͜ͱΛ֬ೝ͢Δ
  43. Migrating to AndroidX 2. Enable Jetifier Jetifier will: - Migrate

    your third-party dependencies to use AndroidX Jetifier will not: - Migrate your source code - Migrate generated code
  44. Migrating to AndroidX 3. Update Dependencies Ұ෦ͷ3rdPartyϥΠϒϥϦ͸Ξοϓσʔτ͕ඞཁ Annotation ProcessorͳͲͷίʔυੜ੒ܥͷ΋ͷ͸ ผ్ରԠ͕ͻͭΑ͏ʹͳΔ

  45. Migrating to AndroidX 4. Use Studio Refactor > Migrate to

    AndroidX
  46. Migrating to AndroidX 5. Bash Script or Edit yourself Replace

    all source code instance of support library packages with their AndroidX version https://goo.gle/androidx-migration-script
  47. Migrationͷ͋ͱͰ • Patterns we can't automate • ext౳ʹهड़͍ͯ͠Δόʔδϣϯม਺Λॻ͖׵͑Δ͜ͱ͸͠ ͯ͘Εͳ͍ͷͰɺͦ͜͸ࣗ෼Ͱ΍Δඞཁ͋Γ •

    Proguard files • Build scripts • όʔδϣϯ͕alpha൛ͱ͔ʹͳ͍ͬͯΔ΍ͭ΋͋Δ͔Βɺࣗ ෼Ͱstable൛ͱ͔ʹม͑Δ
  48. ॴײ

  49. ॴײ • Debug࣌ͷTipsͳͲ͸πʔϧ͕ߋ৽͞Εͯ΋ɺ
 طʹ࣋ͬͯΔ஌ࣝͰରԠ͕ͪ͠ͳͷͰɺߋ৽͍ͯ͜͠͏ • ηογϣϯΛݟճͬͯεϓϦϯτʹ௥ՃػೳΛ͢Ͱʹ3ͭ
 ͘Β͍ੵΜͩͷͰɺͥͻηογϣϯΛ •

  50. ͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ