All Projects → enginebai → Androidbase

enginebai / Androidbase

Licence: mit
Android project template for Gradle Kotlin DSL + 100% Kotlin + Base module + Extensions = ❤️

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Androidbase

Kotlin Android Mvvm Starter
Android Kotlin Starter is a starter project which implements MVVM Pattern.
Stars: ✭ 276 (+200%)
Mutual labels:  rxjava2, architecture-components, template
DaggerExoPlayer
This repository demonstrates ExoPlayer injection with Dagger2
Stars: ✭ 58 (-36.96%)
Mutual labels:  rxjava2, architecture-components
flickr-android
A small sample app to showcase architecting app using Clean Architecture and MVVM
Stars: ✭ 25 (-72.83%)
Mutual labels:  rxjava2, architecture-components
News Sample App
A sample news app which demonstrates clean architecture and best practices for developing android app
Stars: ✭ 334 (+263.04%)
Mutual labels:  rxjava2, architecture-components
AndroidMultiModuleCleanArchTemplate
An Android kotlin project template with Dagger2, Rx and Architecture Components
Stars: ✭ 33 (-64.13%)
Mutual labels:  rxjava2, architecture-components
AndroidCleanArchitecture
Android Project with clean android architecture contain Dagger, Retrofit, Retrofit, Android archtecture components, LiveData with MVVM architecture
Stars: ✭ 22 (-76.09%)
Mutual labels:  rxjava2, architecture-components
Android-Mvi-Starter
Android MVI Starter application
Stars: ✭ 19 (-79.35%)
Mutual labels:  rxjava2, architecture-components
Devmvp
一键生成MVP架构基础代码-Android Studio模板
Stars: ✭ 145 (+57.61%)
Mutual labels:  rxjava2, template
Movienight
MovieNight is a sample Android application that uses the clean architecture approach and is written in Kotlin.
Stars: ✭ 744 (+708.7%)
Mutual labels:  rxjava2, architecture-components
Base Mvvm
App built to showcase basic Android View components like ViewPager, RecyclerView(homogeneous and heterogeneous items), NavigationDrawer, Animated Vector Drawables, Collapsing Toolbar Layout etc. housed in a MVVM architecture
Stars: ✭ 18 (-80.43%)
Mutual labels:  rxjava2, architecture-components
Ribble
Simple Dribbble Client using Dribbble API, fully written in Kotlin 😱 ❤️
Stars: ✭ 872 (+847.83%)
Mutual labels:  rxjava2, architecture-components
android-kick-start-modular
Android Kick Start Project Template Framework FrogoBox || Admob, MVVM Archictecture || Clean Architecture Modularization
Stars: ✭ 16 (-82.61%)
Mutual labels:  rxjava2, architecture-components
TeamManagerApp
A sample app structure using the MVVM architecture LiveData, RxJava, ViewModel, Room and the Navigation Arch Components.
Stars: ✭ 36 (-60.87%)
Mutual labels:  rxjava2, architecture-components
Starwars
A sample modular Android app written in Kotlin using Rx, Koin, Coroutines, Dagger 2 and Architecture components
Stars: ✭ 41 (-55.43%)
Mutual labels:  rxjava2, architecture-components
Fountain
Android Kotlin paged endpoints made easy
Stars: ✭ 175 (+90.22%)
Mutual labels:  rxjava2, architecture-components
Retrokotlin
Simple Android app to show how unit testing with MockWebServer and Architecture Components (ViewModel + LiveData)
Stars: ✭ 55 (-40.22%)
Mutual labels:  rxjava2, architecture-components
Wemake Python Package
Bleeding edge cookiecutter template to create new python packages
Stars: ✭ 235 (+155.43%)
Mutual labels:  project-template, template
Pagingroom
Demonstrates various ways of using Paging library with Room (LiveData, RxJava, custom datasource)
Stars: ✭ 139 (+51.09%)
Mutual labels:  rxjava2, architecture-components
Modern Cpp Template
A template for modern C++ projects using CMake, Clang-Format, CI, unit testing and more, with support for downstream inclusion.
Stars: ✭ 690 (+650%)
Mutual labels:  project-template, template
Market tech challenge
A best use case Android application sample with latest patterns. This app is developer as part of Kariyer.net Tech Challenge.
Stars: ✭ 31 (-66.3%)
Mutual labels:  rxjava2, architecture-components

Language License

AndroidBase

The AndroidBase project provides an Android app project template that setups for Gradle Kotlin DSL, it also provides some base classes or extensions to accerate your android development.

You can use this template or download the base module.

There also provides two helper branches:

  • If you'd like to see how the simple Gradle Kotlin DSL project works (i.e. a new android app project just created by Android Studio and use Gradle Kotlin DSL), you can checkout to the branch gradle-kotlin-dsl to take a look.
  • If you'd like to see how the base module works or contribute to this project, you can checkout to the branch library.

Setup for Template Project

  1. Just click on Clone this template button to create a new repo starting from this template. Or you can clone this project by git clone [email protected]:enginebai/AndroidBase.git .
  2. Change your project name in settings.gradle.kts.
  3. Set your application ID in Versions.kt
  4. Set the package name in AndroidManifest.xml file of :app module .
  5. Select com.enginebai.project directory in "Project" tool window and rename package for your app.
  6. Specify your retrofit base URL in NetworkModule.kt file.
  7. Start to design your main layout xml file fragment_main.xml and fragment class.
  8. Specify your MainFragment.kt name in navigation graph xml file.
  9. That's all. Start your app development journey now 🎉.

Get Started with Template Project

  1. You can start your development as usual in app module.
  2. This projects encourges you to use single activity architecture with naivgation component, you will create new fragment that extends the BaseFragment for your all UI pages.
  3. This project uses koin as our dependency injection framework, you will define the modules in di package and add those modules in AppContext.defineDependencies()
  4. You will handle errors with ExceptionHandler, we register a function that will handle errors that are passed to Subscriber.onError(Throwable) for RxJava; for non-RxJava exception, you will inject ExceptionHandler and pass exception to accept(Throwable) function. More detail usage you can check ExceptionHandler, there are some instructions that guide you how to write your custom exception handling logic.

Good Practices of Gradle Kotlin DSL

  • Add all dependencies versions in Versions.kt
object Versions {
    const val kotlin = "1.3.50"
    const val awesomeLibrary = "x.y.z"
    // TODO: add the library version
    ...
}
  • Define all 3rd-party dependencies in Dependencies.kt, and use all versions definition in Versions.kt.
object Dependencies {
    const val rxJava = "io.reactivex.rxjava2:rxjava:${Versions.rxJava}"
    // TODO: add standalone dependency here!
    ...

    object Kotlin {
        const val gradlePlugin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Versions.kotlin}"
        const val stdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Versions.kotlin}"
    }

    // TODO: add inner object for sub-modules of library
    object AndroidX {
        ...
    }
    ...
}
  • Always import dependency from Dependencies.kt in build.gradle.kts file.
dependencies {
	implementation(Dependencies.Glide.core)
	"kapt"(Dependencies.Glide.compiler)
    implementation(project(":base"))
    // TODO: add by using dependency imported from `Dependencies.kt` file
    ...
}
  • Configure android build script in Config.kt.
fun Project.configAndroid() = this.extensions.getByType<BaseExtension>().run {
    compileSdkVersion(Versions.Android.sdk)
    defaultConfig {
        minSdkVersion(Versions.Android.minSdk)
        targetSdkVersion(Versions.Android.sdk)
        versionCode = Versions.App.versionCode
        versionName = Versions.App.versionName
        // TODO: add your configurations
        ...
    }
    ...
}

It's equivalent to the old way android { ... } block in build.gradle file

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"
    defaultConfig {
        applicationId "com.enginebai.moviehunt"
        // TODO: add your configurations
        ...
    }
    ...
}
  • Add all configuration variables inside Config object in Config.kt, and add buildConfigField(...) to include.
object Config {
    const val API_ROOT = "\"https://api.themoviedb.org/3/\""
    const val IMAGE_API_ROOT = "\"https://image.tmdb.org/t/p/\""
    // TODO: add your constants here, make sure to add extra double quotes for string value.
}

fun Project.configAndroid() = this.extensions.getByType<BaseExtension>().run {
    compileSdkVersion(Versions.Android.sdk)
    defaultConfig {
        ...

        buildConfigField("String", "API_ROOT", Config.API_ROOT)
        buildConfigField("String", "IMAGE_API_KEY", Config.IMAGE_API_ROOT)
        // TODO: add your varialbes here imported from `Config` object
        ... 
    }
    ...
}
  • Add the common dependencies that share between modules to Dependencies.kt
fun Project.importCommonDependencies() {
    dependencies {
        ...
        implementation(Dependencies.material)
        // TODO: add your common dependencies
        .. 
    }
}

Note: Remember to perform Gradle Sync to apply your changes when updating any files in buildSrc.

Modules Structure

  • :app module: That's your app module, just like a normal Android app project. Or you can create a new modules (ex: :common) for that if you use multi-modules project or libraries. There is the sample build.gradle.kts for library module:
plugins {
    id("com.android.library")
    commonPlugins.forEach { id(it) }
}

configAndroid()
importCommonDependencies()

dependencies {
    implementation(Dependencies.whatever)
    ...
}
  • /buildSrc: It enables you to write the build script (*.gradle.kts files) in kotlin to manage dependencies and gets better IDE completion support. It gives you a way to develop build code more like regular code. More information please check official document.

Download for Base Module

Step 1. Add it to your root build.gradle.kts:

allprojects {
    repositories {
        ...
        maven("https://jitpack.io")
    }
}

Step 2. Add the dependency:

  • Versions.kt:
const val androidBase = "1.0.0"
  • Dependencies.kt:
const val androidBase = "com.github.enginebai:AndroidBase:${Versions.androidBase}"
  • App module build.gradle.kts:
dependencies {
    ...
    implementation(Dependencies.androidBase)
}

Included Libraries

There are some default 3rd-party libraries imported in this project, and provide some popular dependencies (following listed) in buildSrc/Dependencies.kt file that you can choose to use. Feel free to add/remove those dependencies.

  • Android Architecture Components, part of Android Jetpack for give to project a robust design, testable and maintainable.
  • Retrofit / OkHttp, Square open-source RESTful API and http client.
  • RxJava / RxAndroid, reactive programming for JVM.
  • Koin, kotlin light-weight dependency injection.
  • Timber, for logging.
  • Epoxy, for RecyclerView complex view layout.
  • Paging, for pagination loading of RecyclerView.
  • Navigation, for single activity and fragment routing.
  • Room, for local persistence database.

Useful Extensions

LICENSE

Copyright (c) 2020 Engine Bai

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].