Coder Social home page Coder Social logo

androidtddbootstrap's Introduction

Android TDD bootstrap project

Master branch build status codecov.io Android Arsenal

An Android TDD bootstrap project, using a collection of new technology, obeying the best practices, inspired by some popular architectures, and developed with many handy tools.

Why another bootstrap project?

From the beginning of the year 2015, our team started a new project, and before we developing functionality in detail, we have tried to create a well-architected project from scratch, with well designed network layer, data layer, asynchronous execution, communication between modules, and last but not least: unit test and integrated testing support. After several months of development, we found some drawbacks of our current architecture, and also found some popular architectures, then I decided to extract our original well designed architecture and make it open-source, with amendment according to the drawbacks and features from the new popular architectures we've found. Recently I have seen a lot of bootstrap/base Android projects, including JakeWharton's u2020, mobiwiseco's Android-Base-Project, etc, but none of these projects cover all the features I include in this AndroidTDDBootStrap project. That's why I want more people to see this repo, and I also want get feedback from more people to improve this project.

Architecture

Based on the project architecture I'm currently working on, YOLO, and inspired by popular architectures: Android Clean Architecture, Against Android Unit Tests: The Square way.

perfect_android_model_layer

  • MVP: YaMvp, Yet another Mvp library. Super simple, but with enough functionality.
  • Dependency injection
  • Dagger2, A fast dependency injector for Android and Java.
  • ButterKnife, View "injection" library for Android.
  • Model layer, 完美的安卓 model 层架构(上)
  • OkHttp, An HTTP+SPDY client for Android and Java applications.
  • Retrofit, Type-safe HTTP client for Android and Java by Square, Inc.
  • Gson, A Java library that can be used to convert Java Objects into their JSON representation.
  • SQLBrite, A lightweight wrapper around SQLiteOpenHelper which introduces reactive stream semantics to SQL operations..
  • SQLDelight, Generates Java models from CREATE TABLE statements.
  • AutoValue, Generated immutable value classes for Java 1.6+.
  • auto-value-gson, AutoValue Extension to add Gson De/Serializer support.
  • auto-value-parcel, An Android Parcelable extension for Google's AutoValue.
  • Reactive programming
  • RxJava – Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.
  • RxAndroid, RxJava bindings for Android.
  • RxBinding, RxJava binding APIs for Android's UI widgets.
  • RxLifecycle, Lifecycle handling APIs for Android apps using RxJava.
  • Communication between modules: EventBus, Android optimized event bus that simplifies communication between Activities, Fragments, Threads, Services, etc. Less code, better quality.
  • Image loader: Fresco, An Android library for managing images and the memory they use.
  • Other core libraries
  • SafelyAndroid, Build safely Android app, no more Activity not found error and Activity state loss error!
  • RetroLambda, Backport of Java 8's lambda expressions to Java 7, 6 and 5.
  • ThreeTenABP, An adaptation of the JSR-310 backport for Android.
  • AutoBundle, AutoBundle generates boilerplate code for field binding with android.os.Bundle.
  • FlexLayout, A powerful Android layout view that use java expression in layout params to describe relative positions.
  • Developer tools
  • XLog, Method call logging based on dexposed.
  • LeakCanary, A memory leak detection library for Android and Java.
  • ANR-WatchDog, A simple watchdog that detects Android ANR (Application Not Responding) error and throws a meaningful exception.
  • AndroidPerformanceMonitor, A transparent ui-block detection library for Android. (known as BlockCanary)
  • strictmode-notifier, Improving StrictMode's report on Android.
  • Timber, A logger with a small, extensible API which provides utility on top of Android's normal Log class.
  • OkHttp Logging Interceptor, An OkHttp interceptor which logs HTTP request and response data.
  • Ok2Curl, Convert OkHttp requests into curl logs.
  • Stetho, Stetho is a debug bridge for Android applications, enabling the powerful Chrome Developer Tools and much more.
  • android-git-sha-plugin, Automatically add current GIT SHA value to your apk. It can rise an error if the current git branch is dirty.
  • Codestyle, Customized base on Square java-code-styles.
  • Others
  • Iconfy, Android integration of multiple icon providers such as FontAwesome, Entypo, Typicons,...
  • Fabric, Crash report.
  • Once, A small Android library to manage one-off operations.
  • Unit test
  • Junit && Android Junit
  • Following the Square Way
  • Android Unmock Gradle Plugin, Gradle plugin to be used in combination with the new unit testing feature of the Gradle Plugin / Android Studio to use real classes for e.g. SparseArray.
  • mockito, Tasty mocking framework for unit tests in Java.
  • RESTMock, HTTP Server for Android Instrumentation tests.
  • Espresso
  • Continuous integration
  • Travis CI
  • Code quality, customized from Vincent Brison's vb-android-app-quality repo
  • AndroidCodeQualityConfig
  • Checkstyle, Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. By default it supports the Google Java Style Guide and Sun Code Conventions, but is highly configurable. It can be invoked with an ANT task and a command line program.
  • Find bugs, FindBugs is a defect detection tool for Java that uses static analysis to look for more than 200 bug patterns, such as null pointer dereferences, infinite recursive loops, bad uses of the Java libraries and deadlocks.
  • PMD, PMD is a source code analyzer.
  • Lint
  • Code coverage
  • Jacoco && Codecov

Project structure

  • base
  • The so called architecture part, and base classes, best practice, etc.
  • model
  • Business related data layer, entities, API, REPO, etc.
  • app
  • App functionality.
  • package organization
  • package by layer v.s. package by feature, read more about the Package organization part of this blog, and Package by feature, not layer.
  • package by layer + package by feature + network API, data object, REPO are organized in the single model library module, but inside model module, classes are organized by feature + app functionality are organized by feature, mvp, di, ui code are organized together

Build tips

  • Sign key config

    Place KeyStore file in some place, and create a TemplateKeyStore.properties, and config the KeyStore in it, include keystore, keystore.password, key.password, key.alias.

  • To clone all submodules, please use git clone --recursive [email protected]:Piasy/AndroidTDDBootStrap.git

  • use flavor to control server configuration, use build type to control log behavior

  • dev for development server, prod for production server

  • debug enable log and dev tools, disable crash and analytics, release against it

Dev tips

  • Create Activity
  • TODO use the MVP feature generator
  • Unit test
  • use the check*.sh script in buildsystem dir
  • Run ./buildsystem/ci.sh before git push.

Todo

  • CheckStyle
  • re-arch the provider package
  • Espresso test of presentation module
  • refactor AppComponent
  • facebook BUCK integration integrate with OkBuck
  • Update dependencies
  • refactor modules
  • NDK integrate now it's easy to integrate NDK with Android gradle build tools 2.2.2
  • MVP source generator plugin
  • MVVM branch
  • react native branch
  • kotlin branch

Coverage

codecov.io

Acknowledgement

  • Thanks for our team, YOLO.
  • Thanks for my colleague & mentor, promeG.

androidtddbootstrap's People

Contributors

piasy avatar zhoulujue avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.