This is a template to build an Android app applying good practices and using a clean architecture, you will see that the code is super decoupled with external frameworks and even with the same Android framework, this will help you to model your domain purely in Kotlin without generating external dependencies.
In the following images you will see how the app is built and what its levels of abstraction are.
Architecture guide recommended by google for android
Run verification commands:
./gradlew app:check
or
./gradlew app:test
executing tests
This project contains DeteKt configurations, run next command in your terminal.
./gradlew app:detekt
Run next command in your terminal for generate jacoco coverage report
./gradlew app:testDebugUnitTestCoverage
Install sonarqube using Home brew
brew install sonarqube
brew install sonar-scanner
After installation of the sonarqube you need to start the services. Please enter the command brew services start sonarqube in the terminal. You can create your credentials by hitting this URL: http://localhost:9000/
Update your sonar project setting on build.gradle:
sonarqube {
properties {
property "sonar.projectVersion", "1.0"
property "sonar.projectName", "your app name in sonar"
property "sonar.projectKey", "your app name in sonar"
property "sonar.host.url", "http://localhost:9000/" // or https://sonarcloud.io/
property "sonar.login", "xxxxxxxxxxxxxxx" //Generated in sonarqube
property "sonar.language", "kotlin"
property "sonar.sources","src/main/java"
property "sonar.java.coveragePlugin", "jacoco"
property "sonar.coverage.jacoco.xmlReportPaths", "${rootProject.projectDir}/app/build/reports/jacoco/debug/jacoco.xml"
}
}
Again in the Android Studio, hit this command in terminal
./gradlew sonarqube
Below you will find the libraries used to build the template and according to my criteria the most used in android development so far.
- Jetpack Compose, for ui components.
- Koin - dependencie provider.
- Retrofit - networking.
- Gson - json parser.
- Coil with image loader.
- Kotlin coroutines, for concurrency.
- Mockk, testing library.
- WebMockServer, mock service response.