Slide 1

Slide 1 text

GDG Incheon What’s new in Android Studio in 4.0, 4.1, 4.2 HyeonSeok Noh Google Developer Experts for Android

Slide 2

Slide 2 text

GDG Incheon Roadmap 2019 2020 v3.5 Project Marble v3.6 v4.0 View Binding Emulator - Google Maps UI Leak Detection Design Tool Updates Motion Editor “Live” Layout Inspector Build Analyzer CPU Profiler update v4.1 v4.2

Slide 3

Slide 3 text

GDG Incheon New Logo?!

Slide 4

Slide 4 text

4.2 Support for Compose Improved instrumentation testing 4.1 Material Design Project IDE configuration Dagger navigation Emulator directly Database Inspector Custom View Preview 4.0 Java8 library desugaring Build Analyzer CPU Profiler upgrades New Motion Editor Live Layout Inspector Kotlin Android live templates Updated proguard rules android studio

Slide 5

Slide 5 text

GDG Incheon Stable Android Studio 4.0 • Java8 library desugaring • Build Analyzer • CPU Profiler upgrades • New Motion Editor • Live Layout Inspector • Kotlin Android live templates • Updated proguard rules

Slide 6

Slide 6 text

GDG Incheon Lambda Expressions Default interface method try with resource … Android Studioীࢲ Java8੉ۆ? 2013 2014 2015 2016 2017 2018 2019 2020 Google I/O 2013 Android Studio ߊ಴ 3.0 ߊ಴ Java 8 ૑ਗ द੘ (D8)

Slide 7

Slide 7 text

GDG Incheon Android Gradle Plugin 3.0.0+ https://developer.android.com/studio/write/java8-support

Slide 8

Slide 8 text

GDG Incheon Android Gradle Plugin 3.0.0+ https://developer.android.com/studio/write/java8-support

Slide 9

Slide 9 text

GDG Incheon Sample, Required APIs Using time/stream

Slide 10

Slide 10 text

Default

Slide 11

Slide 11 text

java.time.LocalDate ࢎਊ઺ Default

Slide 12

Slide 12 text

java.time.LocalDate ࢎਊ઺ Default java.util.stream.Stream ࢎਊ઺

Slide 13

Slide 13 text

GDG Incheon Lambda Expressions Default interface method try with resource … Android Studio 4.0+ 2013 2014 2015 2016 2017 2018 2019 2020 3.0 ߊ಴ Java 8 ૑ਗ द੘ (D8) 4.0 ߊ಴ Support Java API Desugar (D8) min APIী ৔ೱਸ ߉૑ঋҊ Java ঱য੄ APIܳ ࢎਊоמ Google I/O 2013 Android Studio ߊ಴

Slide 14

Slide 14 text

GDG Incheon coreLibraryDesugaringEnabled android { compileOptions { // ࢜۽਍ ঱য APIܳ ૑ਗೞӝ ਤೠ Flag coreLibraryDesugaringEnabled true // Java compatibility ࢸ੿ী Java 8 ੸ਊ sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.9' } android { defaultConfig { // minSdkVersion 20 ੉ೞੋ ҃਋ ೙ࣻ multiDexEnabled true } }

Slide 15

Slide 15 text

GDG Incheon coreLibraryDesugaringEnabled ੸ਊ റ Clear Required API

Slide 16

Slide 16 text

Java 8 API ࢎਊਸ ਤೠ ഐജࢿ ӝ߈੄ ੿ࠁо ୶оؽ ੸ਊ ੹ࠁ׮ ਊ۝ ૐо Desugar

Slide 17

Slide 17 text

Desugar j$.time.LocalDate ࢎਊ઺ LocalDate.now()

Slide 18

Slide 18 text

Desugar j$.time.LocalDate ࢎਊ઺ j$.util.stream.Stream ࢎਊ઺ LocalDate.now() stream()

Slide 19

Slide 19 text

GDG Incheon Supported APIs Android Gradle plugin 4.0.0 or higher ● java.util.stream ● java.time ● java.util.function ● java.util.{Map,Collection,Comparator} ● java.util.Optional, java.util.OptionalInt, java.util.OptionalDouble ● java.util.concurrent.atomic (new methods on AtomicInteger, AtomicLong, AtomicReference) ● ConcurrentHashMap (with bug fixes for Android 5.0) https://developer.android.com/studio/write/java8-support#library-desugaring

Slide 20

Slide 20 text

GDG Incheon Summary .java .javac .class 3rd party libs D8/R8 App .dex(s) j$ .dex Library desugaring j$.util.stream j$.time … {

Slide 21

Slide 21 text

// build.gradle (Default) android { buildFeatures { buildConfig = true viewBinding = false dataBinding = false aidl = true renderScript = true resValues = true shaders = true } } New options to enable or disable build features GDG Incheon ● ਗೞח ӝמ ױਤ ഝࢿച оמ ● Module ױਤ build Configuration ࢸ੿ Deprecated android { dataBinding.enabled = false viewBinding.enabled = false }

Slide 22

Slide 22 text

Project-wide default settings GDG Incheon // project gradle.properties android.defaults.buildfeatures.viewbinding=true android.defaults.buildfeatures.databinding=true android.defaults.buildfeatures.aidl=true android.defaults.buildfeatures.buildconfig=true android.defaults.buildfeatures.renderscript=true android.defaults.buildfeatures.resvalues=true android.defaults.buildfeatures.shaders=true ● Project ੹୓ ӝࠄ ࢸ੿ ୊ܻ

Slide 23

Slide 23 text

GDG Incheon on AGP 4.0+ on Android Studio 4.0+ Analyze the project's build performance Build… ing… ing…

Slide 24

Slide 24 text

GDG Incheon Build Analyzer • ࠽٘ दрਸ Ѿ੿ೞח ೦ݾٜਸ ࠙ࢳ • Task ѐࢶਵ۽ ੹୓ ࠽٘ दрਸ ઴ੌ ࣻ ੓ח ನੋ౟ https://developer.android.com/studio/build/build-analyzer

Slide 25

Slide 25 text

GDG Incheon Build Analyzer ~ Example

Slide 26

Slide 26 text

GDG Incheon Build Analyzer Pluginsਵ۽ ߊࢤೞח दр ഛੋ OSS ۄ੉ࣃझ јन਷ ݒ ࠽٘दী јनೡ ೙ਃח হ׮ (੹୓ ઺ 313s / 68.2%)

Slide 27

Slide 27 text

GDG Incheon Build Analyzer ~ Tasks • Critical Path Task੄ दрਸ ഛੋ • ࠽٘ दрਸ Ѿ੿ೞח ઱ਃ Taskܳ ഛੋ

Slide 28

Slide 28 text

GDG Incheon Build Analyzer ~ Tasks Critical Path Task

Slide 29

Slide 29 text

GDG Incheon Build Analyzer ~ Tasks Critical Path Task

Slide 30

Slide 30 text

GDG Incheon Build Analyzer ~ Warnings ೦࢚ ز੘ೞח Taskо ੓ח ҃਋, 1. Task ࣻ੿ 2. Library Issue ١۾

Slide 31

Slide 31 text

GDG Incheon Advanced Tips ~ Build Scan ./gradlew assembleDebug --scan https://guides.gradle.org/creating-build-scans/

Slide 32

Slide 32 text

GDG Incheon Upgrade CPU Profiler Inspect system traces : https://developer.android.com/studio/profile/cpu-profiler#inspect-traces • CPU Profiler UI ѐࢶ • ೠ ߣী ݽٚ झۨ٘ܳ ഛੋ (Redner, App-Main, Others Thread) • ؊਌ ૒ҙ੸ਵ۽ ఐ࢝ • ࠙ࢳ ಁօ ѐࢶ

Slide 33

Slide 33 text

GDG Incheon CPU Profiler GDG Incheon

Slide 34

Slide 34 text

GDG Incheon CPU Profiler GDG Incheon Timeline Analysis

Slide 35

Slide 35 text

GDG Incheon CPU Profiler GDG Incheon

Slide 36

Slide 36 text

GDG Incheon Inspect system traces ● ఋ੐ ۄੋীࢲ੄ п झۨ٘ীࢲ ߊࢤೞח ੉߮౟ ● ݽٚ CPU ௏যীࢲ झۨ٘ ഝز ● UI झۨ٘ ߂ ೐ۨ੐ ࣘب ੷ೞܳ ਬߊೞח ߽ݾ അ࢚ ഛੋ GDG Incheon

Slide 37

Slide 37 text

GDG Incheon Design tools

Slide 38

Slide 38 text

GDG Incheon Design Tools Timeline 2.2 3.0 3.3 3.4 3.5 3.6 4.0 Layout Editor Alpha Layout Editor Navigation Editor Resource Manager Project Marble Constraint Layout Motion Layout Motion Editor

Slide 39

Slide 39 text

GDG Incheon Split View update UX • Code/Split/Design View ੹ജ ѐࢶ • ఫझ౟ о੉٘ ୶о

Slide 40

Slide 40 text

GDG Incheon Material Icons Filled Outlined Rounded Sharp Two Tone ● 1,000+ icons ● 5 ઙܨ੄ ప݃ File > New > Image Assert / Vector Assert

Slide 41

Slide 41 text

GDG Incheon Motion Editor • Required ConstraintLayout 2.0.0-beta3

Slide 42

Slide 42 text

Demo

Slide 43

Slide 43 text

GDG Incheon Live Layout Inspector • 3D View (Rotate View) • Live Updates • Modify Layer Spacing • Required API Level 29+ on Devices

Slide 44

Slide 44 text

Layout Inspector Example

Slide 45

Slide 45 text

Issues https://issuetracker.google.com/issues/157714512 GDG Incheon

Slide 46

Slide 46 text

GDG Incheon Property value resolution stack • ܻࣗझ ч੉ द੘غח ਤ஖ܳ ઑࢎ • Override غח ܻࣗझ ഛੋ https://developer.android.com/studio/releases#4-0-0-live-layout-inspector

Slide 47

Slide 47 text

Property value resolution stack

Slide 48

Slide 48 text

GDG Incheon Layout Validation ۨ੉ইਓ੄ ਬബࢿ Ѩࢎ (Multi Devices, Color, Font Size)

Slide 49

Slide 49 text

Layout Validation

Slide 50

Slide 50 text

Color Blind

Slide 51

Slide 51 text

Font Sizes

Slide 52

Slide 52 text

Custom Validation ୶о ജ҃ ࢸ੿ਵ۽ Preview ഛੋ

Slide 53

Slide 53 text

GDG Incheon Kotlin Android live templates Preferences | Editor | Live Templates

Slide 54

Slide 54 text

GDG Incheon Smart editor for code shrinker rules • R8 ௏٘ ୷ࣗ ӏ஗ ౵ੌ(proguard-rules.pro)ਸ ৌ ٸ झ݃౟ ಞ૘ӝ ӝמ • Class, Method, Field ী ؀ೠ ࡅܲ ఐ࢝җ Rename ૑ਗ

Slide 55

Slide 55 text

GDG Incheon Smart editor for code shrinker rules

Slide 56

Slide 56 text

GDG Incheon Beta 5 Android Studio 4.1 • Material Design Project • IDE configuration • Dagger navigation • Emulator directly • Database Inspector • Custom View Preview

Slide 57

Slide 57 text

Material Design Components : Updated themes and styles Android Studio 4.1 ࠗఠ ݠ౭ܻ঴ ٣੗ੋ੉ ӝࠄ ੸ਊ

Slide 58

Slide 58 text

Material Design Components

Slide 59

Slide 59 text

Material Design Components ~4.0 : colorPrimary 4.1+ : purple_500 ex)

Slide 60

Slide 60 text

Material Design Components

Slide 61

Slide 61 text

Material Design Components Support Dark Theme

Slide 62

Slide 62 text

GDG Incheon Configuration directory changes Window macOS Linux Syntax: %APPDATA%\Google\ Example: C:\Users\YourUserName\AppData\Roaming\Google\AndroidStudioPreview4.1 Syntax: ~/Library/Application Support/Google/ Example: ~/Library/Application Support/Google/AndroidStudioPreview4.1 Syntax: ~/.config/Google/ Example: ~/.config/Google/AndroidStudioPreview4.1 IntelliJ IDEA 2020.1 | Default IDE directories

Slide 63

Slide 63 text

GDG Location Dagger navigation support GDG Incheon New gutter actions Dagger ҙ۲ ௏٘ܳ औѱ ఐ࢝ ੄ઓࢿ ҕә੗(Provider) ఐ࢝ ੄ઓࢿ ࢎਊ੗(Related) ఐ࢝

Slide 64

Slide 64 text

Dagger navigation Example GDG Incheon

Slide 65

Slide 65 text

Emulator directly ীޯۨ੉ఠܳ built-in प೯ GDG Incheon

Slide 66

Slide 66 text

GDG Incheon Emulator directly

Slide 67

Slide 67 text

GDG Incheon Emulator directly ୶о ஶ౟܀ ӝמ • Show Zoom Controls

Slide 68

Slide 68 text

GDG Incheon Emulator directly ୶о ஶ౟܀ ӝמ • Show Zoom Controls • Crop Device Frame

Slide 69

Slide 69 text

Launch in a tools window AS 4.1 or Higher Preferences | Tools | Emulator Emulator੄ प೯ ਤ஖ܳ ߸҃ ● On : IDEী ࠽౟ੋػ ഋక ● Off : ӝઓ ߑध

Slide 70

Slide 70 text

GDG Incheon Database Inspector A live database tool (AS 4.1 Canary 6+) • Query database • Table ؘ੉ఠ ୓௼ ߂ ࣻ੿ • Room/Sqlite ૑ਗ image caption : https://medium.com/androiddevelopers/database-inspector-9e91aa265316 • Live Updates • Run Query Action

Slide 71

Slide 71 text

GDG Incheon Navigate Menu ● View - Tools Windows - Database Inspector ● ೞױ Tool ݫ׏ - Database Inspector GDG Incheon

Slide 72

Slide 72 text

Database Inspector Required min API Level 26 (Oreo) GDG Incheon

Slide 73

Slide 73 text

Database Inspector Inspection App ࢶఖ GDG Incheon

Slide 74

Slide 74 text

Database Inspector DB / Table ഛੋ @Query ۽ ੿੄ػ Action प೯ (Database Inspectionदী݅ ഝࢿച) GDG Incheon

Slide 75

Slide 75 text

GDG Incheon GDG Location Sqlite statement Example

Slide 76

Slide 76 text

GDG Incheon Update table Example GDG Incheon

Slide 77

Slide 77 text

GDG Incheon Live updates Example GDG Incheon

Slide 78

Slide 78 text

GDG Incheon Custom View Preview

Slide 79

Slide 79 text

GDG Incheon android studio 4.0

Slide 80

Slide 80 text

GDG Incheon android studio 4.0

Slide 81

Slide 81 text

Custom View (code) GDG Incheon android studio 4.1

Slide 82

Slide 82 text

GDG Incheon Updated CPU Profiler https://developer.android.com/studio/preview/features#4.1-ui-upgrades • Box selection • Summary tab • Add SurfaceFlinger and VSYNC on Display Data

Slide 83

Slide 83 text

CPU Profiler on AS 4.1 GDG Incheon

Slide 84

Slide 84 text

GDG Incheon Recurring trace event • ӝࠄ trace (Count, Average, Max, Min …) • о੢ ӟ प೯ ୊ܻ ഛੋ

Slide 85

Slide 85 text

GDG Incheon Canary 5 Android Studio 4.2 • Support for Jetpack Compose • Improved instrumentation testing

Slide 86

Slide 86 text

GDG Incheon Jetpack Compose

Slide 87

Slide 87 text

GDG Incheon Jetpack Compose Android ୭न UI toolkit ● ࢶ঱੸ੋ UI Patterns ● ੸਷ ࣻ੄ ௏٘ ● ૒ҙ੸ ● ࡅܲ ѐߊ җ੿ ● ъ۱ೠ ࢿמ ● Unbundled UI ஹನք౟ ● Kotlin API ࢎਊ ● അ੤ח Developer Preview Jetpack Compose : https://developer.android.com/jetpack/compose GDG Incheon

Slide 88

Slide 88 text

GDG Incheon 2020.07 0.1.0-dev15 2019.10 0.1.0-dev01 2010.01 0.1.0-dev04 2019.05

Slide 89

Slide 89 text

GDG Incheon New Jetpack Composetooling ● Compose preview ● Interactive preview ● Deploy to device GDG Incheon

Slide 90

Slide 90 text

GDG Incheon Compose preview GDG Incheon

Slide 91

Slide 91 text

GDG Incheon PreviewParameter

Slide 92

Slide 92 text

GDG Incheon ● Tools Attribute੄ Sample Data৬ ਬࢎ ● ױੌ ۨ੉ইਓਸ ࠂࣻ ؘ੉ఠ۽ ഛੋೞҊ र ਷ ҃਋ী ਬਊೣ ● PreviewParameterProvider ● Data ઁҕਸ ҳഅೞח ੋఠಕ੉झ ● PreviewParameter ● Data ࣻन੗ܳ ૑੿ೞח Annotation PreviewParameter GDG Incheon

Slide 93

Slide 93 text

GDG Incheon Interactive preview ● Composable ױਤ۽ Preview प೯ ● पઁ৬ زੌೞѱ ز੘

Slide 94

Slide 94 text

GDG Incheon Interactive preview

Slide 95

Slide 95 text

Deploy Preview

Slide 96

Slide 96 text

Deploy Preview

Slide 97

Slide 97 text

GDG Incheon Improved instrumentation testing

Slide 98

Slide 98 text

GDG Incheon Improved instrumentation testing

Slide 99

Slide 99 text

GDG Incheon Improved instrumentation testing

Slide 100

Slide 100 text

GDG Incheon Emulators

Slide 101

Slide 101 text

Foldables ● Foldable ױ݈੄ Hinge ૑ਗ ● Emulator Extended controls > Virtual sensors ীࢲ ߸҃ ● അ੤ח ࣻزਵ۽ config.ini ী Hinge ੑ۱ਵ۽ ഝࢿച https://androidstudio.googleblog.com/2020/06/emulator-30017-canary.html

Slide 102

Slide 102 text

GDG Incheon Hinge angle sensor hw.sensor.hinge = yes hw.sensor.hinge.count = 2 hw.sensor.hinge.ranges = 0-360,0-360 hw.sensor.hinge.defaults = 180,180 hw.sensor.hinge.areas = 0-987-1440-0, 0-1974-1440-0 hw.sensor.posture_list = 1, 2, 3, 4 hw.sensor.hinge_angles_posture_definitions = 0-30 & 0-30, 30-150 & 30-150, 150-210 & 150-210, 210-360 & 210-360 https://cs.android.com/android/platform/superproject/+/master:prebuilts/ android-emulator/linux-x86_64/lib/hardware-properties.ini;l=535 Add lines to ~/.android/avd/avdName.avd/config.ini

Slide 103

Slide 103 text

GDG Incheon Create AVD ● Open AVD (on 4.1 or Higher) ● Category > Tablet ● Create 13.5” Freeform

Slide 104

Slide 104 text

GDG Incheon

Slide 105

Slide 105 text

v4.0 Motion Editor “Live” Layout Inspector Layout Validation Custom View Preview CPU Profiler Update R8 Rules Editing Build Analyzer Dynamic Feature Dependency Intellij 2019.3 android studio Database Inspector Dependency Injection tools Faster Apply Changes Gradle Config Caching Android Emulator in IDE Instrumentation Testing Profiler UI Updates Native Memory Profiling New Gradle API MLKit & TFLite Model Import Intellij 2020.1 Wireless ADB Debugging Compose Interactive Preview Compose Animation Visualization ConstraintLayout Visualization Compose Theme Preview Compose Deploy to Device Sample Data API for Compose Compose Editing Support Test Failure Retention Intellij 2020.2 v4.1 v4.2

Slide 106

Slide 106 text

GDG Incheon Reference Android Studio Release ● https://developer.android.com/studio/releases#4-0-0 ● https://developer.android.com/studio/preview/features#4.1 ● https://developer.android.com/studio/preview/features#4.2 ● https://android-developers.googleblog.com/2020/05/android-studio-4.html Medium ● https://medium.com/androiddevelopers/layout-inspector-1f8d446d048 ● https://medium.com/androiddevelopers/database-inspector-9e91aa265316 ● https://medium.com/androiddevelopers/whats-new-in-android-studio-system-trace-5841465c5935 ● https://medium.com/androiddevelopers/support-for-newer-java-language-apis-bca79fc8ef65 ● https://medium.com/androiddevelopers/dagger-navigation-support-in-android-studio-49aa5d149ec9 ● https://medium.com/androiddevelopers/android-at-large-how-to-bring-optimized-experiences-to-the-big-screen- a50a6784e59d

Slide 107

Slide 107 text

GDG Incheon Thanks!! http://pluu.github.io @pluulove