Android is used on billions of devices, from high-end mobile phones to in-flight entertainment systems. The Android OS protects billions of devices, efficiently manages resources and keeps them running smoothly, but sometimes makes it harder to develop great apps. To simplify the development process, we released a preview of Architecture Components at Google I/O, which provides guidance for App development architectures and libraries for common tasks such as lifecycle management, data persistence, and more. With the help of these basic components, developers can write modular apps with less boilerplate code and focus on innovation rather than repetitive manual labor — an infrastructure we will continue to improve in the future.

Today we are pleased to announce the release of Room and Lifecycles Architecture build Library stable version 1.0, whose apis are now available in production apps and libraries. And we strongly recommend using these apis for developers who need help with App architecture and local storage (it’s recommended, but not required). Lifecycle management is also integrated into the Support Library, so developers can use these apis in standard categories such as AppCompatActivity.

Although we only launched the stable version today, the beta component is already integrated into the billions of downloaded apps. Architectural components help many top development teams, such as Zapppos, focus more time on more critical work.

Before architecture components were published, we had our own implementation of the ViewModel, which was guaranteed to remain the same even after configuration changes through loaders and Dependency Injection. We recently switched to the ViewModel implementation in the architecture component and got rid of rework altogether, finding that we could spend more time on design, business logic, and testing than boilerplate code or worrying about the Android life cycle.

We also started using LiveData — a data container that is aware of the Activity lifecycle — to fetch and display network data without worrying about subscription management for network calls. — David Henry, Android software engineer at Zappos

Architectural components provide simple, flexible, and operational solutions to common problems developers encounter, allowing them to focus on building a first-class user experience. Behind it, we bundle together the core building blocks through the App Architecture guide.

Lifecycles

Every Android developer has faced life cycle issues, where the operating system starts, stops, and destroys activities. This means that developers need to manage component state, such as observables used to update the user interface, according to different phases of the lifecycle. Lifecycles help developers create “lifecycle-aware” components that manage their own Lifecycles, reducing the likelihood of memory leaks and crashes. The lifecycle library is the foundation for other architectural components, such as LiveData.

Learn more about Lifecycles:

https://developer.android.google.cn/topic/libraries/architecture/lifecycle.html

LiveData

LiveData is a core component of an observatory-based lifecycle awareness. LiveData is an Observable of the interface code (Observer). When the data held by LiveData changes, it notifies the corresponding interface code to update it. At the same time, LiveData holds a reference to Lifecycle, which means it will make updates when the Lifecycle of the code is started or resumed, And stop updating when LifecycleOwner is destroyed. With LiveData, developers can easily build more secure and responsive user interfaces with better performance.

Learn more about LiveData:

https://developer.android.google.cn/topic/libraries/architecture/livedata.html

ViewModel

The ViewModel separates the view’s data and logic from entities with lifecycle characteristics, such as activities and fragments. The ViewModel does not disappear until the associated Activity or Fragment is completely destroyed, that is, the view data is retained even in the event that a rotation of the screen causes the Fragment to be recreated. ViewModels not only eliminate common lifecycle issues, but also help build a more modular and testable user interface.

Learn more about ViewModel:

https://developer.android.google.cn/topic/libraries/architecture/viewmodel.html

Room

Almost all apps need to store data locally. SQLite has been available on Android since the earliest versions, but using SQLite directly can be a chore. That’s why we launched Room, a simple object mapping layer. It’s just as powerful as SQLite, but saves a lot of the hassle of repetitive coding. Some of its features, such as compile-time data query validation and built-in migration support, make it easier for developers to build robust persistence layers. And Room can be integrated with LiveData to provide an observable database and life-cycle aware objects. Room is simple, powerful, and reliable, and does a great job of managing local storage, and we highly recommend that developers try it out.

Learn more about Room:

https://developer.android.google.cn/topic/libraries/architecture/room.html

App Architecture guide and more

One final note: We’ve written the App Architecture Guide, which covers several key principles for all developers as well as specific guidance for architectural components. Because some developers have told us that clear, consistent guidance documentation is important, we have now updated the developer documentation to indicate architectural components where appropriate. In addition, we have also published a series of related videos, Codelab and App samples on our website, and more will be added.

App Architecture Guide:

https://developer.android.google.cn/topic/libraries/architecture/guide.html

Android Architecture Components

https://developer.android.google.cn/topic/libraries/architecture/index.html

Keep an eye on this area

Although the first set of architectural components has been released in stable form, we know there is a long way to go. Over the past few months, we have been working diligently to improve your feedback. Recently, through the Alpha beta channel, we also released a new component — PagedList, to solve the problem of using RecyclerView to process large data sets. The journey is just beginning and we have many more important components in development that we hope to see in the coming months.

To learn more about PagedList:

https://developer.android.google.cn/topic/libraries/architecture/paging.html

Submit feedback:

https://developer.android.google.cn/topic/libraries/architecture/feedback.html

We hope that architectural components will free developers to focus on innovation and creating unique new experiences on mobile. We are excited to finally release a stable version ready for production. In particular, we would like to thank the developers for their valuable advice and we hope you can leave your comments in the discussion section below. For those of you who have been waiting for the stable version, why not start downloading it today?

Recommended reading:

Shenzhen Google Playtime 2017 perfect end!

What are the changes to Android support library V26?

Android Oreo downloadable fonts

Android Instant Apps are supported on more than 500 million devices

Android 8.1 Developer Preview — Oreo update ready for ML machine learning