• Stars
    star
    1,755
  • Rank 26,530 (Top 0.6 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created almost 9 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Android Development Culture

QualityMatters

This app follows all principles of Android Development Culture Document.

What does it have:

  • CI (Travis)
  • Unit tests (some are Robolectric, some are plain JUnit tests with mocked android.jar).
  • Integration tests to see that HTTP, REST, JSON parsing and RxJava work well in composition.
  • Functional (UI) tests (Espresso with custom rules, mocked server and Screen-architecture) to check that app works according to the expectations from the user's point of view.
  • Static code analysis (FindBugs, PMD, Android Lint, Checkstyle) (see root build.gradle).
  • Code coverage codecov.io
  • Developer Settings Menu where you can enable/disable Stetho, LeakCanary, etc. See full list below (feel free to add more tools!).
  • Git sha & build time without breaking incremental compilation! (Thanks to Paperwork)
  • MVP, RxJava, Dagger 2, Retrofit 2 and so on.

Made with ❤️ by Artem Zinnatullin https://twitter.com/artem_zin.

To build the project run sh build.sh (yep, that easy, because it should be easy).

Screenshots:

Tests

Unit tests

Unit tests live mostly in src/unitTests but the app also has debug and release specific code—so there are also debugUnitTests and releaseUnitTests.

Unit tests check classes/methods in isolation from others, all dependencies are mocked.

All unit tests run on the JVM, no emulator or device is required. Mostly, unit tests run with mocked android.jar (built-in feature of Android Gradle Plugin). Some tests require things like Intent, etc. and such tests run using Robolectric.

The app has custom unit test runner which is required in order to override and mock some dependencies using Robolectric, like Analytics. Who needs real Analytics in Unit tests?

Integration tests

Integration tests live in src/integrationTests.

Integration tests check composition of multiple classes, for example OkHttp + Retrofit + Jackson + RxJava == API level, mostly all classes are real and not mocked, but for instance, we mock web server in integration tests.

All integration tests run on the JVM using Robolectric.

Also, you might notice that the app has custom integration test runner. It's required in order to override and mock some dependencies, like Analytics. Again, who needs real Analytics in integration tests?

Functional (UI) tests

The app has functional (UI) tests that live in src/functionalTests.

Functional tests check how the product (Android app) works from user's point of view. Basically, functional tests check app's UI for different use cases.

All functional tests run on connected emulator/device via Instrumentation API.

Also, you might notice that the app has custom functional test runner (yep). It's required to override and change implementation of some dependencies, like Analytics—instead of posting tons of useless data to Analytics during functional tests, we simply output it to the LogCat!

Developer Settings

Tools:

  • Stetho — inspect the app via Chromium Developer Tools (network requests, db, preferences and so on). Must-have for developers.
  • LeakCanary — detect memory leaks without IDE! Must-have for QAs and developers.
  • TinyDancer — see frame rate right on your screen. Must-have for QAs and developers.
  • Lynx — see LogCat output right in the app, useful for QAs and developers.

Details of implementation

Developer Settings are present only in debug build type. Libraries and resources used for Developer Settings are compiled into debug build only—main source set knows only little abstractions over Developer Settings just to initialize real implementation in the debug build code. In release build type DeveloperSettingsModule (Dagger) just returns no-op implementation of DeveloperSettingsModel.

Why only debug builds? The answer is simple — dex limit. LeakCanary brings about 3k methods, Stetho brings about 2k and so on. The more tools you add to Developer Settings, the bigger the apk you receive. Situation is even worse if your main code gets near 65k methods. In our production app we had to turn on multidex for debug builds.

Package structure

Many people ask why this app has component-based package structure: presenters, models, etc. instead of the feature-based one: itemslist, developersettings, etc.

With component-based structure of packages, new persons on the project (like those who read the code of this app) can easily find presenters, views, models, etc. within the app. If you read the code and want to quickly move to some class related to the current one you can simply press t right on the GitHub and search for the required file!

More Repositories

1

RxJavaProGuardRules

ProGuard rules for RxJava shipped as AAR!
Shell
719
star
2

TheContext-Podcast

Podcast about Android Development with Hannes Dorfmann, Artem Zinnatullin, Artur Dryomov and wonderful guests!
625
star
3

RxUi

Implementation of pure functional concept of talking to Android View layer in a Reactive way
Java
263
star
4

AndroidStudio-VM-Options

JVM options for smoother Android Studio experience
140
star
5

android-wail-app

DEPRECATED Android Last.fm scrobbler. Recruiters: please don't look at this project.
Java
121
star
6

droidcon-nyc-2017-puzzlers

RxJava and Kotlin Puzzlers! Follow our Engineering Blog for article with explanation
Kotlin
101
star
7

AutoJackson

Small example of AutoValue/AutoParcel + Jackson
Java
73
star
8

AssertParcelable

Checks Parcelable implementation.
Java
48
star
9

dev-null-android

Dev null as Service comes to android!
Java
48
star
10

jet-image-loader

WP7+ fast and powerfull image loader with memory and storage caching for your projects!
C#
44
star
11

RxKoans

(Experimental) set of excersices in for of unit tests to improve your Rx (RxJava, Project Reactor, etc) skills
Kotlin
35
star
12

java-uncheck-exceptions

0-deps library for throwing checked exceptions as unchecked without wrapping!
Kotlin
19
star
13

Android-AsyncTask-Executor

DEPRECATED You want to execute your AsyncTask concurrently on any version of Android OS? You need AsyncTaskExecutor!
Java
18
star
14

error-prone-performance

Project to benchmark and profile Error-Prone performance to uncover bottlenecks.
Java
13
star
15

RxJavaV1V2Adapter

Adapter between RxJava v1 and v2
Java
13
star
16

android-lint-cli

Prebuilt jars of Android Lint CLI tool.
9
star
17

build-demo

Demo of building same code with different build systems.
Java
8
star
18

ScreenValley

NO MORE FRAGMENTS HELL
Java
6
star
19

yota-test-task

Test task for Yota company
Java
3
star
20

macos-input-sound-toggle

Tiny macOS executable to toggle input sound on and off preserving prev volume level.
Shell
2
star
21

Android-VK-Api

DEPRECATED! (Not supported + code base is not so good) Need to work with vk.com in your Android app? Just use Android-VK-Api library!
Java
2
star