Android Architecture Blueprints

The Android framework provides a lot of flexibility(灵活) in deciding(决定) how to organize and architect an Android app. While this freedom is very valuable(有价值的), it can also lead(领导) to apps with large classes, inconsistent(不一致) naming schemes(方案), as well as mismatching(不匹配) or missing architectures. These types of issues(问题) can make testing, maintaining(维护) and extending your apps difficult.

The Android Architecture Blueprints project demonstrates(演示) strategies(策略) to help solve(解决) or avoid(避免) these common problems. This project implements the same app using different architectural concepts(概念) and tools.

You can use the samples in this project as a learning reference(参考), or as a starting point for creating your own apps. The focus of this project is on demonstrating how to structure your code, design your architecture, and the eventual(最终) impact of adopting(采用) these patterns on testing and maintaining your app. You can use the techniques(技术) demonstrated here in many different ways to build apps. Your own particular(特别) priorities(优点) will impact how you implement the concepts in these projects, so you should not consider these samples to be cononical(规范) examples. To ensure the focus is kept on the aims described above, the app uses a simple UI.

Explore the samples

This project hosts each sample app in separate repository branches. For more information, see the README.md file in each branch.

Stable samples

Sample Description
todo-mvp Demonstrates a basic Model-View-Presenter(MVP) architecture and provides a foundation on which the other samples are built. This sample alse acts as a reference point for comparing and contrasting the other samples in this project.
todo-mvp-loaders Feches data using the Loaders API.
todo-databinding Uses the Data Binding Library.
todo-mvp-clean Uses concepts from Clean Architecture.
todo-mvp-dagger Uses Dagger2 to add support for dependency injection.
todo-mvp-contentproviders Based on the todo-mvp-loaders sample, this version fetches data using the Loaders API, and also makes use of content providers.
todo-mvp-rxjava Uses RxJava to implement concurrency, and abstract the data layer.
todo-mvvm-databinding Based on the todo-databinding sample, this version incorporates the Model-View-ViewModel pattern.
dev-todo-mvp-tablet Adds a master and detail view for tablets.
dev-todo-mvvm-rxjava Based on the todo-rxjava sample, this version incorporates the Model-View-ViewModel pattern.

External samples

External samples are variants that may not be in sync with the rest of the branches in this repository.

Sample Description
todo-mvp-fragmentless Uses View objects instead of Fragment objects.
todo-mvp-conductor Uses the Conductor framework to refactor the app to use a single Activity architecture.
todo-mvp-kotlin A translation of todo-mvp to Kotlin

Why a to-do app?

The app in this project aims to be simple enough that you can understand it quickly, but complex enough to showcase diffcult design decisions and testing scenarios. For more information, see the app’s specification.

Choose a sample for your app

Each sample includes a dedicated README.md file where you cna find related metrics, as well as subjective assessments and observations by contributors. The following factos are worth considering when selecting a particular sample for your app:

  • The size of the app you are developing
  • The size and experience of your team
  • The amount of maintenance that you are expecting to have to do
  • Whether you need a tablet layout
  • Whether you need to support multiple platforms
  • Your preference for the compactness of your codebase

For more information on choosing and comparing samples, see the following pages:

  • Samples at a glance
  • How to compare samples

Open a sample in Android Studio

To open one of the samples in Android Studio, begin by checking out one of the sample branches, and then open the todoapp/ directory in Android Studio. The following series of steps illustrate how to open the todo-mvp sample.

Note: The master branch does not compile.

Clone the repository:

git clone git@github.com:googlesamples/android-architecture.git

Checkout the todo-mvp sample:

git checkout todo-mvp

Note: To review a different sample, replace todo-mvp with the name of sample you want to check out.

Finally open the todoapp/ directory in Android Studio.

Contributors

This project is build by the community, and curated by Google as well as other core maintainers.

打赏