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

New in Android Studio

New in Android Studio

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

pluulove (노현석)

December 21, 2019
Tweet

More Decks by pluulove (노현석)

Other Decks in Programming

Transcript

  1. Android Dev Summit 2019 extended Seoul New in Android Studio

    GDE for Android GDG Korea Android Organizer HyeonSeok.Noh
  2. 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. Build Speed • Build ࠙ࢳद Build Task੄ Critical Pathܳ ӝળਵ۽

    ഛੋ • Critical Path : Gradle੉ োࣘ੸ਵ۽ प೯ • ઱ਃ ҃۽о Build दрਸ Ѿ੿ • 4.0.0-alpha03 ੉࢚ ೙ਃ
  4. Multi Preview • ׮নೠ ٣߄੉झ ߂ Configuration җ ҙ۲ػ ۨ੉ইਓਸ

    زदী ޷ܻ ࠅ ࣻ ੓ח ٣੗ੋ بҳ • Pixel Devices • Locale • Color Blind Mode • IDE ହ੄ য়ܲଃ ࢚ױী੓ח Multi Preview చਸ ௿ܼೞৈ ഝࢿച
  5. Android ѐߊद੄ Ҋ޹ • Java? Kotlin? • ੉ ӝמ਷ ࢎਊೡ

    ࣻ ੓חо? • ݽٚ ೐۽Ӓې߁ীࢲ minSdkVersionী ৊੉ח ޙઁٜ • Shadow / ShadowColor / Java 8 Retrolambda, jack, desugar, Kotlin
  6. ~ 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
  7. 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
  8. Desugaring // build.gradle android { compileOptions { // ࢜۽਍ Language

    APIܳ ૑ਗೞӝ ਤೠ Flag coreLibraryDesugaringEnabled true // Java compatibility ࢸ੿ী Java 8 ੸ਊ sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } }
  9. 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
  10. View Binding • View৬ ࢚ഐ੘ਊೞח ௏٘ܳ औѱ ੘ࢿ • ViewBinding

    ഝࢿചद XML Layout੄ Binding ௿ېझ ࢤࢿ • ؀ࠗ࠙੄ ҃਋, findViewByIdܳ ؀୓ • Android Studio 3.6 Canary 11+ ࠗఠ ഝࢿച <!-- ignore --> <LinearLayout ... tools:viewBindingIgnore="true" > ... </LinearLayout>
  11. 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>
  12. 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(...) { ... }
  13. 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(...) { ... }
  14. View Binding private lateinit var binding: ResultProfileBinding @Override fun onCreate(savedInstanceState:

    Bundle) { super.onCreate(savedInstanceState) binding = ResultProfileBinding.inflate(layoutInflater) setContentView(binding.root) } DataBindingҗ زੌೠ ࢎਊߨ
  15. findViewById৬੄ ର੉੼ • Null safety : Viewী ؀ೠ ૒੽ ଵઑܳ

    ࢤࢿ • ੜޅػ View ID۽ ੋೠ NPE ߊࢤ ਋۰ח হ׮ • ੌࠗ࠙ী݅ ੓ח ҃਋ @Nullable • Type safety : XMLীࢲ੄ View Typeҗ ੌ஖ • Layoutҗ ௏٘੄ ࠺ഐജࢿਵ۽ ੋ೧ Compileदী ࠽٘о पಁ
  16. • Data Binding਷ <layout> కӒܳ ࢎਊೠ ۨ੉ইਓ݅ ୊ܻ • View

    Binding਷ ۨ੉ইਓ ߸ࣻ/಴അध ޷૑ਗ • XML੄ ؘ੉ఠ৬ ۨ੉ইਓ ߄ੋ٬ ࠛоמ • ࢎਊ੉ ؊ औҊ ࠽٘ ࣘبী ؏ ৔ೱਸ ષ Data Bindingҗ੄ ର੉੼
  17. @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
  18. Debugging ~ Problem • ٣ߡӦ ઺ Break Point ۄੋਸ ૑աஜ

    • ٣ߡӦ ઺ ୶о௏٘ܳ ؊ ֍Ҋ रয૗ ೧Ѿߨ 1. ನӝೠ׮ 2. ׮द द੘ೠ׮ 3. Apply Changesܳ दبೠ׮
  19. • I/O 19ীࢲ ࣗѐػ ୊਺ ঱ә • ࢜۽਍ Layout Inspector

    • AS 4.0 Canary 4ীࢲ ز੘ • AS 4.0 Canary 5ীࢲ ޷ز੘ • AS 4.0 Canary 6ীࢲ ز੘ Layout Inspector
  20. • Preference - Experimental - Layout Inspector - Enable Live

    Layout Inspector • Install Plugin • Skia Layout Inspector Enable
  21. • 3D View ഋక۽ ۨ੉ইਓ Ө੉ܳ द п੸ਵ۽ ഛੋ оמ

    • അ੤ Live updates਷ Slooooow Reviews
  22. 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 } }