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.
Reducing Startup time with background module loading
You can now declared "lazy" Koin module, to avoid trigger any pre allocation of resources and load them in background with Koin start. This can help avoid to block Android starting process, by passing lazy modules to be laoded in background.
- lazyModule - declare a Lazy Kotlin version of Koin Module
- Module.includes - allow to include lazy Modules
- KoinApplication.lazyModules - load lazy modules in background with coroutines, regarding platform default Dispatchers
- Koin.waitAllStartJobs - wait for start jobs to complete
- Koin.runOnKoinStarted - run block code after start completion
Example:
// Lazy loaded module
val m2 = lazyModule {
singleOf(::ClassB)
}
val m1 = module {
singleOf(::ClassA) { bind<IClassA>() }
}
startKoin {
// sync module loading
modules(m1)
// load lazy Modules in background
lazyModules(m2)
}
val koin = KoinPlatform.getKoin()
// wait for start completetion
koin.waitAllStartJobs()
// or run code after start
koin.runOnKoinStarted { koin ->
// run after background load complete
}
TheMovieDB API: Check this documentation.
Using local properties for define api key:
apiKey="{your-api-key}"
Run check project:
> ./gradlew check
Run tests project:
> ./gradlew test
Below you will find the libraries used to build the template and according to my criteria the most used in android development so far.
- Retrofit, networking.
- Moshi, json parser.
- Glide, with image loader.
- Kotlin coroutines.