Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

ࠓ೔ͷࢿྉ͸ͪ͜Βʹࣄલެ։͍ͯ͠·͢ ⬇ http://ow.ly/kUmN50x4vv9

Slide 5

Slide 5 text

ࢹௌͨ͠ηογϣϯ • 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

Slide 6

Slide 6 text

Some Topics

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

Monitoring and Improving 
 Real-World Stability and Performance Android Vitals׆༻ͯ͠·͔͢ʁ https://youtu.be/mXzy0NX9bSM

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

ηογϣϯͰऔΓ্͛ΒΕ͍֤ͯͨࣾͷରԠࣄྫ • 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()

Slide 29

Slide 29 text

Demystify the Data 
 in Android Studio Profilers ߴػೳͳ1SPGJMFS͕͍ͭͯ·͕͢ɺ ׆༻ͯ͠·͔͢ʁ https://youtu.be/v4kCRZ_O4Lc

Slide 30

Slide 30 text

ProfilerΛ࢖ͬͯϝϞϦϦʔΫͱରቂ͢Δ • CPU / Memory / Network / EnergyͷࢦඪͰݟΕΔ • Memoryʹ Leaked Activities and Fragments ͕૿͑ ͯΔʢAS3.6ʣ

Slide 31

Slide 31 text

Leaked Activities and Fragments ·ͣHeap DumpΛͱΔ ͜͜ʹग़ͯ͘Δ ϦʔΫͯ͠ΔActivity / Fragment

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

Instance View • Depth • Native • Shallow • Retained Size

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

Instance View

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

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

Slide 38

Slide 38 text

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

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

Jetpack / AndroidX • I/O 2018ͰSupport Library Λ androidxͷnamespaceʹ
 Ҡ͢ൃද͕͞Εͨ • ͢ͰʹSupport Library͸28.0.xͰ։ൃ͕ࢭ·͍ͬͯΔ • όάϑΟοΫεɺ৽ػೳ͸AndroidXʹ • ੵۃతʹ࢖͍͖͍͚ͬͯͨͲɺҠߦ͕ɺɺ

Slide 41

Slide 41 text

Migrating to AndroidX • ΄΅͢΂ͯͷϑΝΠϧʹมߋ͕ೖΔͷͰɺ
 ଞ࡞ۀͱฏߦͯ͢͢͠ΊΔͷ͸͓͢͢ΊͰ͖ͳ͍
 ⇢࡞ۀλΠϛϯάΛௐ੔͢Δ • Ұ൪࢝ΊʹɺϓϩδΣΫτΛόοΫΞοϓ͢Δ͜ͱ

Slide 42

Slide 42 text

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

Slide 43

Slide 43 text

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

Slide 44

Slide 44 text

Migrating to AndroidX 3. Update Dependencies Ұ෦ͷ3rdPartyϥΠϒϥϦ͸Ξοϓσʔτ͕ඞཁ Annotation ProcessorͳͲͷίʔυੜ੒ܥͷ΋ͷ͸ ผ్ରԠ͕ͻͭΑ͏ʹͳΔ

Slide 45

Slide 45 text

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

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

Migrationͷ͋ͱͰ • Patterns we can't automate • ext౳ʹهड़͍ͯ͠Δόʔδϣϯม਺Λॻ͖׵͑Δ͜ͱ͸͠ ͯ͘Εͳ͍ͷͰɺͦ͜͸ࣗ෼Ͱ΍Δඞཁ͋Γ • Proguard files • Build scripts • όʔδϣϯ͕alpha൛ͱ͔ʹͳ͍ͬͯΔ΍ͭ΋͋Δ͔Βɺࣗ ෼Ͱstable൛ͱ͔ʹม͑Δ

Slide 48

Slide 48 text

ॴײ

Slide 49

Slide 49 text

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

Slide 50

Slide 50 text

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