Sample Android app that we use at ribot as a reference for new Android projects. It demonstrates the architecture, tools and guidelines that we use when developing for the Android platform (https://github.com/ribot/android-guidelines)
Libraries and tools included:
- Support library 22.1
- RecyclerViews and CardViews
- RxJava and RxAndroid
- Retrofit and OkHttp
- SqlBrite
- EasyAdapter
- Butterknife
- Picasso
- Otto event bus
- Functional tests with Espresso
- Unit tests with Robolectric
- Mockito
- Android SDK.
- Android 5.1 (API 22) .
- Android SDK Tools
- Android SDK Build tools 22.0.1
- Android Support Repository
To build and install the debug version:
./gradlew installDebug
For Android Studio to use syntax highlighting for Automated tests and Unit tests you must switch the Build Variant to the desired mode.
To run unit tests on your machine:
./gradlew testDebug
To run functional tests on connected devices:
./gradlew connectedAndroidTest
The project uses a checkstyle plugin to make sure that the code follows our Android code guidelines
To validate the code run:
./gradlew checkstyle
The project can be distributed using either Crashlytics or the Google Play Store.
To do this, set up a local variable $ANDROID_DISTRIBUTION
to any of the following values:
play-production
play-alpha
play-beta
crashlytics-yourgroupname
crashlytics-yourgroupname2
etc
Then use the following command e.g. on your CI server:
./gradlew clean checkstyle check connectedAndroidTest assembleRelease $(if [[ $ANDROID_DISTRIBUTION == crashlytics-* ]]; then echo crashlyticsUploadDistributionRelease; else echo publishApkRelease; fi )
To quickly start a new project from this boilerplate follow the next steps:
- Download this repository as a zip.
- Change the package name.
- Rename packages in main, androidTest and test using Android Studio.
- In
app/build.gradle
file,packageName
andtestInstrumentationRunner
. - In
src/main/AndroidManifest.xml
andsrc/debug/AndroidManifest.xml
.
- Optionally, in
app/build.gradle
add the signing config to enable release versions. - Optionally, replace Crashlytics API key in AndroidManifest.xml and uncomment Crashlytics lines in
AndroidBoilerplateApplication.java
andapp/build.gradle
- Create a new git repository, see GitHub tutorial.
- Replace the example code with your app code following the same architecture.
- Update
proguard-rules.pro
to keep models (see TODO in file) and add extra rules to file if needed.