Announcing Architecture Components 1.0 Stable
Posted by Lukas Bergstrom, Product Manager, Android Developer Frameworks Team
Android runs on billions of devices, from high-end phones to airplane seatbacks. The Android OS manages resources aggressively to perform well on this huge range of devices, and sometimes that can make building robust apps complicated. To make it easier, we launched a preview of Architecture Components at Google I/O to provide guidance on app architecture, with libraries for common tasks like lifecycle management and data persistence. Together, these foundational components make it possible to write modular apps with less boilerplate code, so developers can focus on innovating instead of reinventing the wheel - and we hope to keep building on this foundation in the future.
Today we're happy to announce that the Room and Lifecycle href="http://developer.android.com/arch">Architecture Components libraries have reached 1.0 stable. These APIs are ready for production apps and libraries, and are our recommendation for developers looking for help with app architecture and local storage (although they're only recommended, not required.) Lifecycles are now also integrated with the href="https://developer.android.com/topic/libraries/support-library/index.html">Support Library, so you can use them with standard classes like AppCompatActivity.
Although we're declaring them stable today, the beta components are already used in apps that together, have billions of installs. Top developers, like Zappos, have been able to spend more time on what's important thanks to Architecture Components:
Prior to the release of Android Architecture Components we had our own ViewModel implementation. We used Loaders and Dependency Injection to persist our ViewModel through config changes. We recently switched to the Architecture Components ViewModel implementation and all that boilerplate went away. We found that we were able to spend more time on design, business logic and testing, and less on writing boilerplate or worrying about Android lifecycle issues.
We've also started to use LiveData which hooks directly into the Activity lifecycle. We use it to retrieve and display network data and no longer have to concern ourselves with network call subscription management.
- David Henry, Android Software Engineer, Zappos
Architecture Components provide a simple, flexible and practical approach that frees developers from some common problems so they can focus on building great experiences. This is based on core building blocks tied together by guidance on app architecture.
Lifecycles
Every Android developer has to deal with the operating system starting, stopping and destroying their Activities. That means managing the state of components - such as observables used to update UI - as you move through the lifecycle. href="https://developer.android.com/topic/libraries/architecture/lifecycle.html">Lifecycles enables the creation of lifecycle-aware components that manage their own lifecycles, reducing the possibility of leaks or crashes. The Lifecycle library is the foundation for other Architecture Components like LiveData.
LiveData
href="https://developer.android.com/topic/libraries/architecture/livedata.html">LiveData is a lifecycle-aware observable that holds data and provides updates. Your UI code subscribes to changes and provides LiveData a reference to its href="https://developer.android.com/reference/android/arch/lifecycle/Lifecycle.html">Lifecycle. Because LiveData is lifecycle-aware, it provides updates when its Lifecycle is started or resumed, but stops providing updates when the LifecycleOwner is destroyed. LiveData is a simple way to build reactive UIs that are safer and more performant.
ViewModel
href="https://developer.android.com/topic/libraries/architecture/viewmodel.html">ViewModel separates ownership of view data and logic from lifecycle-bound entities like Activities and Fragments. A ViewModel is retained until its associated Activity or Fragment is disposed of forever - that means view data survives events like a Fragment being recreated due to rotation. ViewModels not only eliminate common lifecycle issues, they help build UIs that are more modular and easier to test.
Room
Nearly all apps need to store data locally. While Android has bundled SQLite with the platform since version 1, using it directly can be painful. href="https://developer.android.com/topic/libraries/architecture/room.html">Room is a simple object-mapping layer that provides the full power of SQlite with less boilerplate. Features like compile-time query verification and built-in migration make it easier to build a robust persistence layer, while integration with LiveData lets Room provide database-backed, lifecycle-aware observables. Room blends of simplicity, power and robustness for managing local storage, and we hope you give it a try.
Guide to App Architecture and more
Last but not least, we created a href="https://developer.android.com/topic/libraries/architecture/guide.html">Guide to App Architecture that provides core principles applicable to all developers, and specific guidance on using Architecture Components together. Because we've heard from you that clear and consistent guidance is important, today we're updating developer documentation to point to Architecture Components where appropriate. We also have a rich set of videos, codelabs and sample apps available at the href="http://developer.android.com/arch">Architecture Components site, with more to come.
Watch this space
Although the first set of Architecture Components is now stable, we know there's more work to do. Over the last few months, we've listened to href="https://developer.android.com/topic/libraries/architecture/feedback.html">your feedback and made improvements. We also recently launched a new Architecture Component, href="https://developer.android.com/topic/libraries/architecture/paging.html">PagedList, to alpha, in response to your feedback that handling large datasets with RecyclerView is too difficult. This is just the beginning - we have more major components under development that we're looking to announce in the upcoming months.
Our hope with Architecture Components is to free developers to focus on providing unique new experiences for mobile devices. We're glad we can finally announce them as stable for production use. We'd like to thank the community, which has given such great feedback along the way, and we look forward to continuing the discussion in the comments of this post. Finally, for those of you who've been waiting for this stable launch, href="http://developer.android.com/arch">get started today.
Komentar
Posting Komentar