A collection of samples to discuss and showcase different architectural tools and patterns for Android apps.

Overview

Android Architecture Blueprints v2

Illustration by Virginia Poltrack

Android Architecture Blueprints is a project to showcase different architectural approaches to developing Android apps. In its different branches you'll find the same app (a TODO app) implemented with small differences.

In this branch you'll find:

  • Kotlin Coroutines for background operations.
  • A single-activity architecture, using the Navigation component to manage fragment operations.
  • A presentation layer that contains a fragment (View) and a ViewModel per screen (or feature).
  • Reactive UIs using LiveData observables and Data Binding.
  • A data layer with a repository and two data sources (local using Room and remote) that are queried with one-shot operations (no listeners or data streams).
  • Two product flavors, mock and prod, to ease development and testing (except in the Dagger branch).
  • A collection of unit, integration and e2e tests, including "shared" tests that can be run on emulator/device or Robolectric.

Variations

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

Stable samples - Kotlin

Sample Description
master The base for the rest of the branches.
Uses Kotlin, Architecture Components, coroutines, Data Binding, etc. and uses Room as source of truth, with a reactive UI.
dagger-android
[compare]
A simple Dagger setup that uses dagger-android and removes the two flavors.
usecases
[compare]
Adds a new domain layer that uses UseCases for business logic.

Old samples - Kotlin and Java

Blueprints v1 had a collection of samples that are not maintained anymore, but can still be useful. See all project branches.

Why a to-do app?

A demo illustraating the UI of the app

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

What is it not?

  • A UI/Material Design sample. The interface of the app is deliberately kept simple to focus on architecture. Check out Plaid instead.
  • A complete Jetpack sample covering all libraries. Check out Android Sunflower or the advanced Github Browser Sample instead.
  • A real production app with network access, user authentication, etc. Check out the Google I/O app, Santa Tracker or Tivi for that.

Who is it for?

  • Intermediate developers and beginners looking for a way to structure their app in a testable and maintainable way.
  • Advanced developers looking for quick reference.

Opening 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 root directory in Android Studio. The following series of steps illustrate how to open the usecases sample.

Clone the repository:

git clone [email protected]:googlesamples/android-architecture.git

This step checks out the master branch. If you want to change to a different sample:

git checkout usecases

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

Finally open the android-architecture/ directory in Android Studio.

License

Copyright 2019 Google, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for
additional information regarding copyright ownership. The ASF licenses this
file to you under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.
Issues
  • Sample MVVM with RxJava

    Sample MVVM with RxJava

    I was thinking about doing a sample with MVVM but with RxJava not with databinding. What do you all think?

    New sample community request 
    opened by florina-muntenescu 27
  • New Sample: Model View Intent

    New Sample: Model View Intent

    New sample proposal

    I'd like to create a new sample to illustrate the Model View Intent pattern. Full Android examples for MVI are hard to find. It's a pattern that has seen wide adoption in the Javascript and .NET world. Target audience include, but not limited to:

    • Developers making the pivot from an imperative to declarative style of programming.
    • Developers looking for best-practices in functional or reactive programming on Android.

    Here are some articles/examples explaining the core principles of MVI and unidirectional flow:

    • http://hannesdorfmann.com/android/model-view-intent
    • https://cycle.js.org/model-view-intent.html
    • http://thenewstack.io/developers-need-know-mvi-model-view-intent/

    Proposed stack

    I'm hoping to use specific libraries to achieve this in the cleanest possible way. A requirement with the android-architecture samples is to use accepted industry standard. A few of these libraries are new as of this year, but I believe they still fulfill that requirement. I've taken the time to establish a small 'pedigree' for each.

    The following are battle-tested libraries. Battle tested here means that they have documented use, in production, at major companies with a large user base. Places such as Square, Groupon, Trello, Shopify, etc. One notable exception is RxJava2. RxJava 2 has major community backing, and will see a production release later this month.

    Also, the following all have well-know, senior maintainers with established track records. Below a detailed list with rationale/credentials:

    New sample 
    opened by kanawish 20
  • Migration to Dagger Android/Contributes Injector

    Migration to Dagger Android/Contributes Injector

    This pr updates the Dagger sample to now us modern best practices such as subclassing DaggerApplication as well as the new @ContributesInjector construct.

    opened by digitalbuddha 18
  • Shrinker error: extraneous input '[]' expecting ')'

    Shrinker error: extraneous input '[]' expecting ')'

    I download the android-architecture-todo program, and them i run it. but i got wrong, the follow is the message. I don't know how to do ? 2016-05-12 21 49 17

    bug 
    opened by Jack-Xiao 17
  • I've converted the todo-mvp branch to kotlin

    I've converted the todo-mvp branch to kotlin

    https://github.com/SerjSmor/android-architecture

    I would create a pull request if you are interested.

    New sample community request 
    opened by SerjSmor 12
  • New Sample: Using Kotlin coroutines

    New Sample: Using Kotlin coroutines

    I'd like to create a sample that demonstrates the power and elegance of Kotlin coroutines. It will use MVVM, Data Binding and Architecture Components (ViewModel and possibly LiveData). I plan to branch it off dev-todo-mvvm-live-kotlin. The suggested new branch name is dev-todo-mvvm-live-kotlin-coroutines.

    The primary objective is to select and consistently apply a small subset of essential Kotlin coroutine idioms.

    New sample community request 
    opened by alex-chiviliov 12
  • New sample: MVP-RxJava

    New sample: MVP-RxJava

    Based on MVP but using RxJava for asynchronous jobs, event handling and data observation.

    New sample enhancement 
    opened by JoseAlcerreca 12
  • Added strict Null-Ptr checks of context or activity in some fragments

    Added strict Null-Ptr checks of context or activity in some fragments

    Because new version has strict check for null-ptr of context or activity in fragments. It would be nice to have new and early experience with this new gradle feature.

    opened by XinyueZ 11
  • [all] adding CircleCI configuration file

    [all] adding CircleCI configuration file

    At the moment there is only TravisCI configuration file. Adding those for CircleCI would be fairly easy to do and Jose said it could be a nice addition to the project. I am willing to do it if welcomed. In the case I need to merge on all projects, do I need to create a PR for each or one would be enough for the merge-master to pass it on the others?

    enhancement 
    opened by oldergod 9
  • New sample: rxjava2

    New sample: rxjava2

    I was surprised to see the rxjava example still uses rxjava 1. Has there been any work related to an example using rxjava 2 or are there plans on doing this ?

    opened by jonasgeiregat 9
  • Fixed HiltExt

    Fixed HiltExt

    HiltExt returns ActivityScenario so that tests can use moveToState similar to launchInContainer

    opened by uberchilly 2
  • what's the difference of this MVP to MVVM?

    what's the difference of this MVP to MVVM?

    Since the ViewModel is applied, i have no idea whether it is a mvp or mvvm

    opened by metheway 0
  • All Testcases are getting failed

    All Testcases are getting failed

    java.lang.AssertionError: Activity never becomes requested state "[CREATED, RESUMED, DESTROYED, STARTED]" (last lifecycle transition = "PRE_ON_CREATE")
    	at androidx.test.core.app.ActivityScenario.waitForActivityToBecomeAnyOf(ActivityScenario.java:338)
    	at androidx.test.core.app.ActivityScenario.launchInternal(ActivityScenario.java:272)
    	at androidx.test.core.app.ActivityScenario.launch(ActivityScenario.java:195)
    	at com.example.android.architecture.blueprints.todoapp.tasks.TasksActivityTest.createTwoTasks_deleteOneTask(TasksActivityTest.kt:166)
    	at java.lang.reflect.Method.invoke(Native Method)
    	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
    	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    	at androidx.test.internal.runner.junit4.statement.RunBefores.evaluate(RunBefores.java:80)
    	at androidx.test.internal.runner.junit4.statement.RunAfters.evaluate(RunAfters.java:61)
    	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    	at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
    	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
    	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    	at androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:154)
    	at org.junit.runners.Suite.runChild(Suite.java:128)
    	at org.junit.runners.Suite.runChild(Suite.java:27)
    	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
    	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
    	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
    	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
    	at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
    	at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
    	at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:395)
    	at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2219)
    
    

    I never changed anything in the source code, why test cases are getting failed?

    opened by iamkdblue 2
  • Remove duplicate room dependencies call

    Remove duplicate room dependencies call

    Already used in line number 120 & 121.

    opened by sharansalian 0
  • Migrating build logic from Groovy to Kotlin (KTS)

    Migrating build logic from Groovy to Kotlin (KTS)

    Migrate all .gradle (groovy files) to .gradle.kts (Kotlin DSL)

    Benefits Auto-completion and content assist Quick documentation Navigation to source Refactoring and more

    opened by akhilesh0707 0
  • Handle FAB click with data binding

    Handle FAB click with data binding

    opened by lucasfukuda 0
  • Simplify FilteringPopUpMenu inflation

    Simplify FilteringPopUpMenu inflation

    The inflate() method is equivalent to the previous implementation.

    opened by lucasfukuda 2
  • Architecture Sample Proposal with Koin

    Architecture Sample Proposal with Koin

    Hello!

    I would like to propose a version of the app, done with Koin. A branch is almost ready here: https://github.com/InsertKoinIO/architecture-samples/tree/dev-koin

    Are you interested? What is the process to integrate it?

    Thanks.

    opened by arnaudgiuliani 2
  • Fix

    Fix "usecases" link in README.md

    The link text "usecases" is a relative path. I change it to the absolute link https://github.com/android/architecture-samples/tree/usecases

    opened by AlanChiou 0
A collection of samples to discuss and showcase different architectural tools and patterns for Android apps.

Android Architecture Blueprints v2 Android Architecture Blueprints is a project to showcase different architectural approaches to developing Android a

Android 39.1k Jul 27, 2021
Saga of Star wars - An Android sample repo showcasing Clean Arch with MVVM and Epoxy models

Star Wars Universe This is a showcase android application written in Kotlin and follows Clean Code architecture to showcase Characters from the StarWa

Adit Lal 5 Jul 24, 2021
Learn How to use Google Map API for Android from Basic to Advance with complete examples.

Complete-Google-Map-API-Tutorial Learn How to use Google Map API for Android from Basic to Advance. Satellite View 3D Building Map and StreetView Lear

Next 108 Jul 26, 2021
MVVM(Model View ViewModel) sample in Kotlin using the components ViewModel, LiveData and Retrofit library

kotlin-mvvm Languages: English, Spanish MVVM(Model View ViewModel) sample in Kotlin using the components ViewModel, LiveData, the libraries Retrofit,

Eduardo José Medina Alfaro 334 Aug 4, 2021
Android Viper template with Kotlin, Dagger 2, Retrofit & RxJava

Android VIPER Architecture Example This repository contains a detailed sample client-server app that implements VIPER(View-Interactor-Presenter-Entity

OmiSoft 26 Jul 12, 2021
💖组件化+Jetpack+Kotlin+MVVM项目实战,涉及Jetpack相关组件,Kotlin相关技术,协程+Retrofit,Paging3+Room等。

组件化+Jetpack+Kotlin+MVVM 一、项目简介 该项目主要以组件化+Jetpack+MVVM为架构,使用Kotlin语言,集合了最新的Jetpack组件,如Navigation、Paging3、Room等,另外还加上了依赖注入框架Koin和图片加载框架Coil。 网络请求部分使用OkH

fuusy 277 Aug 4, 2021