Posted by David Winer, Product Manager
The ) was released in 2017 and brought two new conveniences to Android development in Kotlin:
- Synthetics let you replace calls to
findViewByIdwithkotlinx.android.syntheticbindings.
- Parcelize allows you to remove boilerplate and easily create , an officially supported library that has deep integration with the Android build toolchain and provides similar functionality as Kotlin synthetics. While we continue to recommend Parcelize, a number of drawbacks have appeared with using Kotlin synthetics:
- They pollute the global namespace
- They don’t expose nullability information
- They only work in Kotlin code
JetBrains originally developed the Android Kotlin Extensions plugin, and together we have discussed the pros and cons of continuing to maintain synthetics: we strive to ensure long term support for APIs where we can but want to guide developers towards best practices that make for healthy codebases and, ultimately, happy users.
Over the course of the next year, our teams will be jointly deprecating synthetics in favor of continuing to support our recommended option, View Binding. Here’s what that means:
- If you are using Parcelize, you can continue to use the same annotations and APIs. The annotation package will change to
kotlinx.parcelize, however, and In your module-level Gradle file, you should start using the standalonekotlin-parcelizeplugin instead ofandroid-kotlin-extensions. You’ll be able to find documentation for Parcelize on the for more details.
The deprecation period starts with .
↗ Original-Artikel auf feedproxy.google.com lesenVollständiger Original-BerichtAusführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf feedproxy.google.com. - They pollute the global namespace
SOCIAL SHARE CARD GENERATOR