Example of migrating from Dagger to Hilt with a real service/repository example

Related tags

Kotlin DaggerToHilt
Overview

DaggerToHilt

Overview

This repo provides a real example of using Hilt for dependency injection. It hits endpoints provided by the Movie Database, and offers the user the cabability of saving movies they want to a local Room database.

Details

This is meant to be a detailed POC of using Hilt in an application with Android best practices.

Specific branches

There are a couple branches in this repo to focus on some of the details of dependency injection. One branch uses Dagger instead of Hilt. You can compare with the base to see how to convert from Dagger to Hilt. This code lab also probide a detailed explanation of migrating to Hilt. https://developer.android.com/codelabs/android-dagger-to-hilt#0
Hilt allows scoping of components to be shared. LoggerExample provides an example of sharing components across multiple classes, and using qualifiers to provide different implementations through Hilt.

Getting started

To run the project yourself, you will need to set up an API key with the Movie Database. Follow the instructions here: https://developers.themoviedb.org/3/getting-started/introduction.
You will need to set up a gradle.properties file in your project root. Your gradle.properties file will look like this:

# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
# Kotlin code style for this project: "official" or "obsolete":
kotlin.code.style=official
# ensure that Hilt can compile with Kotlin 1.5.0
kapt.use.worker.api=false
# API key for hitting Movie Database server
movieDBApiKey="<Your API key here>"

To verify that your API key is set up correctly, run the tests in ServiceImplementationsTest.

You might also like...
[Android Library] Get easy access to device information super fast, real quick
[Android Library] Get easy access to device information super fast, real quick

DeviceInfo-Sample Simple, single class wrapper to get device information from an android device. This library provides an easy way to access all the d

The Superhero app keeps track of the near real-time location of all the volunteers.

Superhero The Superhero app keeps track of the near real-time location of all the volunteers. The app sends requests for emergency tasks to nearby vol

Real life Kotlin Multiplatform project with an iOS application developed in Swift with SwiftUI, an Android application developed in Kotlin with Jetpack Compose and a backed in Kotlin hosted on AppEngine.

Conferences4Hall Real life Kotlin Multiplatform project with an iOS application developed in Swift with SwiftUI, an Android application developed in K

This Project for how to use  MVVM , state flow, Retrofit, dagger hit, coroutine , use cases with Clean architecture.
This Project for how to use MVVM , state flow, Retrofit, dagger hit, coroutine , use cases with Clean architecture.

Clean-architecture This Project for how to use MVVM , state flow, Retrofit, dagger hit, coroutine , use cases with Clean architecture. Why i should us

Simple Service Locator Library

ScrapServiceLocator A small, asynchronous IoC library for Android that might be half compile-time safe (?) Before I start, I'm very poor at English, s

Location Service Manager for Kotlin Multiplatform Mobile iOS and android
Location Service Manager for Kotlin Multiplatform Mobile iOS and android

Location Service Manager for Kotlin Multiplatform Mobile iOS and android Features Provides simple permission settings Dramatically reduce the amount o

Survey-service - Application for creating online surveys and polls

Survey Service Application for creating online surveys and polls Functionality A

Link-converter - A web service that converts links between web url and deeplink for mobile and web applications

Deep Link Converter Linkleri, mobil ve web uygulamaları için web url ile deeplin

Android app of LINDAT translation service

Charles Translator Android app of LINDAT translation service For now just translate Czech - Ukrainian, but if future will be more languages Architec

Owner
null
An example of a test task for creating a simple currency converter application for the Android platform. The app is developed using Kotlin, MVI, Dagger Hilt, Retrofit, Jetpack Compose.

Simple Currency Converter Simple Currency Converter Android App by Isaev Semyon An example of a test task for creating a simple currency converter app

Semyon Isaev 1 Nov 8, 2021
Example Multi module architecture Android project using MVVM, Dynamic Features, Dagger-Hilt, Coroutines and Navigation Components

ModularDynamicFeatureHilt An Android template project following a multi module approach with clean architecture. It has been built following Clean Arc

Mbuodile Obiosio 25 Nov 23, 2022
Crypto-candlestick-service - Crypto candlestick service Coding Challenge

Coding Challenge Your task is to build a system that enables users to view price

Moses Thomas 0 Feb 6, 2022
Multi module architecture Android template project using MVVM, Dagger-Hilt, and Navigation Components

ModularAppTemplate An Android template project following a multi module approach with clean architecture. It has been built following Clean Architectu

Mbuodile Obiosio 7 May 23, 2022
Android Clean Architechture with MVVM, LiveData, Coroutine, Dagger Hilt, Room, DataStore

MovKu An application that displays a list of popular movies and detail Concepts Tech Stack Kotlin -A modern programming language that makes developers

ꦤꦤꦁ​​ꦲꦫꦶꦥ꦳ꦸꦢꦶꦤ꧀ 3 Jul 29, 2022
Educational App made with Retrofit, Coroutines, Navigation Component, Room, Dagger Hilt, Flow & Material Motion Animations.

TechHub TechHub is a sample educational app that provides courses for people who want to learn new skills in mostly tech-related areas. The goal of th

Jon Areas 32 Dec 20, 2022
A cryptocurrency application with clean architecture (MVVM, Jetpack Compose, Flow, Dagger Hilt)

Amirypto A cryptocurrency application built with Clean architecture and Jetpack component (MVVM, Jetpack Compose, Flow, Hilt, Retrofit). It was made t

null 6 Aug 20, 2022
🍭 GithubSearchKMM - Github Repos Search - Android - iOS - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Dependency Injection, shared KMP ViewModel, Clean Architecture

GithubSearchKMM Github Repos Search - Kotlin Multiplatform Mobile using Jetpack Compose, SwiftUI, FlowRedux, Coroutines Flow, Dagger Hilt, Koin Depend

Petrus Nguyễn Thái Học 50 Jan 7, 2023
This repository contains the article describing my attempt to implement a simple state reducer based on Kotlin Flow and an example app that uses it.

This repository contains the article describing my attempt to implement a simple state reducer based on Kotlin Flow and an example app that uses it.

Maciej Sady 18 Dec 29, 2022
Cleanarchitecture MVVM Hilt base - Android Clean Architecture example project

Android Clean Architecture example project Note: This is project based on MVVM c

Mohsin Javed 4 Aug 30, 2022