New in Android Studio

New in Android Studio

Android Dev Summit 2019 extended Seoul에서 발표한 자료입니다.

354271902cd8ba2762d05b251dfa0f84?s=128

pluulove (노현석)

December 21, 2019
Tweet

Transcript

  1. 1.

    Android Dev Summit 2019 extended Seoul New in Android Studio

    GDE for Android GDG Korea Android Organizer HyeonSeok.Noh
  2. 3.

    Android Auto Emulator Emulator Multi-Display support Google Maps Emulator Integration

    Design Tools : Split View & Zoom Control View Binding Support Profilers: Leak detection Filtering JNI support for Kotlin APK Reloader Intellij 2019.2 v3.6 Jetpack Compose Support Motion Editor Build Attribution Desugaring in D8 & R8 Design Tools : Multi-Preview Updated Layout Inspector Kotlin DSL script (KTS) Proguard Editing Kotlin Live Templates Intellij 2019.3 v4.0+
  3. 10.
  4. 11.

    Build Speed • Build ࠙ࢳद Build Task੄ Critical Pathܳ ӝળਵ۽

    ഛੋ • Critical Path : Gradle੉ োࣘ੸ਵ۽ प೯ • ઱ਃ ҃۽о Build दрਸ Ѿ੿ • 4.0.0-alpha03 ੉࢚ ೙ਃ
  5. 24.

    Multi Preview • ׮নೠ ٣߄੉झ ߂ Configuration җ ҙ۲ػ ۨ੉ইਓਸ

    زदী ޷ܻ ࠅ ࣻ ੓ח ٣੗ੋ بҳ • Pixel Devices • Locale • Color Blind Mode • IDE ହ੄ য়ܲଃ ࢚ױী੓ח Multi Preview చਸ ௿ܼೞৈ ഝࢿച
  6. 31.

    Android ѐߊद੄ Ҋ޹ • Java? Kotlin? • ੉ ӝמ਷ ࢎਊೡ

    ࣻ ੓חо? • ݽٚ ೐۽Ӓې߁ীࢲ minSdkVersionী ৊੉ח ޙઁٜ • Shadow / ShadowColor / Java 8 Retrolambda, jack, desugar, Kotlin
  7. 32.

    ~ Android Studio 3.x • Android Studio 3.0 ੉࢚੄ DEX

    Compiler D8ীࢲ desugaring ೐۽ࣁझܳ ా೧ Java 8 ঱য ӝמ ૑ਗ • lambda expressions • default interface methods • try with resources • Java 8ਸ ॶ ࣻ ੓૑݅, ৈ੹൤ ୭੷ ߡ੹੄ ઁড਷ ઓ੤ Desugaring https://developer.android.com/studio/write/java8-support
  8. 35.

    Android Studio 4.0+ • ୭ࣗ API Levelਸ ਃҳೞ૑ ঋҊ Java

    8 API ࢎਊ оמ • D8਷ ־ۅػ API੄ ҳഅਸ ߹ب Library DEX ౵ੌ۽ ஹ౵ੌ • Library ղࠗী ־ۅػ API ҳഅ੉ ನೣ • Desugaring ೐۽ࣁझח Runtimeद Libraryܳ ࢎਊೞب۾ ௏٘ ੤੘ࢿ Desugaring https://developer.android.com/studio/preview/features#j8-desugar
  9. 36.

    Desugaring // build.gradle android { compileOptions { // ࢜۽਍ Language

    APIܳ ૑ਗೞӝ ਤೠ Flag coreLibraryDesugaringEnabled true // Java compatibility ࢸ੿ী Java 8 ੸ਊ sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } }
  10. 38.
  11. 39.
  12. 42.

    Supported API • 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) Desugaring https://developer.android.com/studio/preview/features#j8-desugar
  13. 44.

    View Binding • View৬ ࢚ഐ੘ਊೞח ௏٘ܳ औѱ ੘ࢿ • ViewBinding

    ഝࢿചद XML Layout੄ Binding ௿ېझ ࢤࢿ • ؀ࠗ࠙੄ ҃਋, findViewByIdܳ ؀୓ • Android Studio 3.6 Canary 11+ ࠗఠ ഝࢿച <!-- ignore --> <LinearLayout ... tools:viewBindingIgnore="true" > ... </LinearLayout>
  14. 46.

    Example // result_profile.xml <LinearLayout ... > <TextView android:id="@+id/name" /> <ImageView

    android:cropToPadding="true" /> <Button android:id="@+id/button" android:background="@drawable/rounded_button" /> </LinearLayout>
  15. 47.

    Example // result_profile.xml <LinearLayout ... > <TextView android:id="@+id/name" /> <ImageView

    android:cropToPadding="true" /> <Button android:id="@+id/button" android:background="@drawable/rounded_button" /> </LinearLayout> public final class ResultProfileBinding implements ViewBinding { @NonNull private final LinearLayout rootView; @NonNull public final Button button; @NonNull public final TextView name; private ResultProfileBinding( @NonNull LinearLayout rootView, @NonNull Button button, @NonNull TextView name) { this.rootView = rootView; this.button = button; this.name = name; } @Override @NonNull public LinearLayout getRoot() { return rootView; } @NonNull public static ResultProfileBinding inflate(...) { ... }
  16. 48.

    View Binding • Binding ௿ېझ੄ ੋझఢझী Viewী ؀ೠ ଵઑо ನೣ

    • Root • IDо ੓ח View public final class ResultProfileBinding implements ViewBinding { @NonNull private final LinearLayout rootView; @NonNull public final Button button; @NonNull public final TextView name; private ResultProfileBinding( @NonNull LinearLayout rootView, @NonNull Button button, @NonNull TextView name) { this.rootView = rootView; this.button = button; this.name = name; } @Override @NonNull public LinearLayout getRoot() { return rootView; } @NonNull public static ResultProfileBinding inflate(...) { ... }
  17. 49.

    View Binding private lateinit var binding: ResultProfileBinding @Override fun onCreate(savedInstanceState:

    Bundle) { super.onCreate(savedInstanceState) binding = ResultProfileBinding.inflate(layoutInflater) setContentView(binding.root) } DataBindingҗ زੌೠ ࢎਊߨ
  18. 50.

    findViewById৬੄ ର੉੼ • Null safety : Viewী ؀ೠ ૒੽ ଵઑܳ

    ࢤࢿ • ੜޅػ View ID۽ ੋೠ NPE ߊࢤ ਋۰ח হ׮ • ੌࠗ࠙ী݅ ੓ח ҃਋ @Nullable • Type safety : XMLীࢲ੄ View Typeҗ ੌ஖ • Layoutҗ ௏٘੄ ࠺ഐജࢿਵ۽ ੋ೧ Compileदী ࠽٘о पಁ
  19. 51.

    • Data Binding਷ <layout> కӒܳ ࢎਊೠ ۨ੉ইਓ݅ ୊ܻ • View

    Binding਷ ۨ੉ইਓ ߸ࣻ/಴അध ޷૑ਗ • XML੄ ؘ੉ఠ৬ ۨ੉ইਓ ߄ੋ٬ ࠛоמ • ࢎਊ੉ ؊ औҊ ࠽٘ ࣘبী ؏ ৔ೱਸ ષ Data Bindingҗ੄ ର੉੼
  20. 54.
  21. 55.

    @Composable fun FilteredList(contacts: List<Contact>, filterText: String = "") { val

    state = +state { filterText } VerticalScroller { Column { TextField(filterText, onValueChange = { state.value = it }) contacts.filter { it.contains(state.value) }.forEach { Row { Image(it.photo) Text(it.name) } } } } } Compose Version
  22. 56.
  23. 57.
  24. 58.
  25. 65.

    Debugging ~ Problem • ٣ߡӦ ઺ Break Point ۄੋਸ ૑աஜ

    • ٣ߡӦ ઺ ୶о௏٘ܳ ؊ ֍Ҋ रয૗ ೧Ѿߨ 1. ನӝೠ׮ 2. ׮द द੘ೠ׮ 3. Apply Changesܳ दبೠ׮
  26. 68.

    • I/O 19ীࢲ ࣗѐػ ୊਺ ঱ә • ࢜۽਍ Layout Inspector

    • AS 4.0 Canary 4ীࢲ ز੘ • AS 4.0 Canary 5ীࢲ ޷ز੘ • AS 4.0 Canary 6ীࢲ ز੘ Layout Inspector
  27. 69.

    • Preference - Experimental - Layout Inspector - Enable Live

    Layout Inspector • Install Plugin • Skia Layout Inspector Enable
  28. 71.
  29. 72.
  30. 73.
  31. 74.
  32. 75.
  33. 76.
  34. 77.
  35. 78.
  36. 79.
  37. 80.

    • 3D View ഋక۽ ۨ੉ইਓ Ө੉ܳ द п੸ਵ۽ ഛੋ оמ

    • അ੤ Live updates਷ Slooooow Reviews
  38. 82.
  39. 83.
  40. 84.
  41. 85.
  42. 86.
  43. 87.
  44. 88.
  45. 89.
  46. 92.
  47. 96.
  48. 97.
  49. 98.
  50. 99.
  51. 100.
  52. 101.
  53. 103.

    Feature // build.gradle android { buildFeatures { // Jetpack Compose

    compose = false buildConfig = true // View Binding / viewBinding.enabled is deprecated viewBinding = false // Data Binding / dataBinding.enabled property is deprecated dataBinding = false aidl = true renderScript = true resValues = true shaders = true } }