Example of Android project showing integration with Kotlin and Dagger 2

Overview

kotlin-dagger-example

This project demonstrate how to setup an Android Project with Kotlin and Dagger 2.

It's based on Dagger 2 example

##Known issues/limitations

When lateinit modifier is used, your variable cannot be used in init{} block. It will not compile. So in that case I suggest to move code from that block into a separate function and then call that function from init{} block.

##More than Dagger

This sample project includes some more dependencies which are very usefull. It's like a base setup for almost every project using Kotlin. So you will find there Anko libraries. You can uncomment Anko's DSL libraries if you need them. There is also a set of Rx dependencies. Rx works really great with Kotlin. At last but not least there my favourite networking dependencies from Square.

Comments
  • Error when upgrading to Kotlin 1.0.0-beta-1103

    Error when upgrading to Kotlin 1.0.0-beta-1103

    Hi! I found this project very helpful to see how to set up kotlin with dagger! But when I tried to use the same method in my app, it didn't work. I realized that it is because I was using a newer version of Kotlin (version 1.0.0-beta-1103).

    If you try updating the Kotlin version in this repo, you will get an error like this: java.lang.NoSuchMethodError: No virtual method provideLocationManager$app_compileDebugKotlin()Landroid/location/LocationManager; in class Lorg/loop/example/AndroidModule;

    Unfortunately, I don't know any solution for this problem. Do you have any ideas?

    opened by lkogler 2
  • Move all classes to Kotlin

    Move all classes to Kotlin

    Is it already possible to move all the code to Kotlin?

    Here is a sample from JetBrains https://github.com/JetBrains/kotlin-examples/tree/master/gradle/kotlin-dagger and only one class is in java. That class uses code that should be generated by Dagger. Unfortunately if I rewrite it to Kotlin then Dagger is not generating anything. According to this blog post http://blog.jetbrains.com/kotlin/2015/06/better-annotation-processing-supporting-stubs-in-kapt/ it should work now. Am I missing something?

    I have tried to use 0.1-SNAPSHOT version of Kotlin as well as the newest 1.0 beta and result is the same.

    opened by mzgreen 2
  • Update README.md

    Update README.md

    Hi! Really interested in using this repo as an example for an upcoming project. I hope you don't mind, but I fixed the markdown formatting to make the section headers render as such.

    opened by ironic-name 1
  • No Dagger 2 generated classes for androidTest (question)

    No Dagger 2 generated classes for androidTest (question)

    Hey Damian, thanks for a great example.

    Have you tried having Components in androidTest folder? It seems that Dagger2 doesn't generate its files for this setup. People solve this problem by using Android-apt plugin when using Java. Do you know anything about how to fix it in pure "Kotlin's way"? Thanks a lot.

    opened by Yougin 1
  • Can't inject Kotlin classes

    Can't inject Kotlin classes

    Hello,

    I've cloned your project and made some changes to see if I can introduce Dagger in my project, I cannot seem to find the way to inject Kotlin classes, and this example doesn't show that. I just inject a Java class..

    The dagger generated classes doesn't seem to be able to find the Kotlin class and failed to compile..

    I have this code in my activity:

    @Inject
     lateinit var presenter: LoginPresenter
    

    And this is the LoginPresenter:

    class LoginPresenter : BasePresenter<LoginView> {
    
        @Inject constructor() {
    
        }
    
       ....
    }
    

    and it throws the following error

    kotlindaggerfailed

    any ideas?

    opened by danieldisu 1
  • Add dependency to fix kotlinx unresolved reference error. Update version.

    Add dependency to fix kotlinx unresolved reference error. Update version.

    Add dependency for Kotlin Extensions for Android plugin to fix unresolved reference error in MainActivity.kt -- import statement: kotlinx

    Update Kotlin to version M12.1 to fix build errors in MainActivity.kt -- assert method

    opened by clkim 0
  • Fix broken headings in Markdown files

    Fix broken headings in Markdown files

    GitHub changed the way Markdown headings are parsed, so this change fixes it.

    See bryant1410/readmesfix for more information.

    Tackles bryant1410/readmesfix#1

    opened by bryant1410 0
  • Organising Gradle dependencies

    Organising Gradle dependencies

    Hi there,

    I took your project as the base of a video tutorial about how to organize the Gradle dependencies and this is the result, I did a Pull Request for my fork with the changes but I'm also sending to you in case you're interested.

    Feel free to close it if you are not interested.

    opened by arturogutierrez 0
Owner
Damian Petla
Android Developer @ Schibsted Tech Polska
Damian Petla
A clean architecture example. Using Kotlin Flow, Retrofit and Dagger Hilt, etc.

android-clean-architecture A clean architecture example. Using Kotlin Flow, Retrofit and Dagger Hilt, etc. Intro Architecture means the overall design

Prieyudha Akadita S. 69 Dec 21, 2022
Sample app to demonstrate the integration code and working of Dyte SDK for android, using Kotlin.

Dyte Kotlin Sample App An example app in kotlin using the Dyte Mobile SDK Explore the docs » View Demo · Report Bug · Request Feature Table of Content

Dyte 8 Dec 3, 2021
Integration-test library for Kotlin and Java

Maya Maya (/ˈmɑːjə/, माया), literally "illusion" or "magic". In Vedic texts it connotes a "magic show, an illusion where things appear to be present,

Konstantin Pavlov 2 Oct 10, 2022
TODO API Client Kata for Kotlin Developers. The main goal is to practice integration testing using MockWebServer

KataTODOApiClient for Kotlin We are here to practice integration testsing using HTTP stubbing. We are going to use MockWebServer to simulate a HTTP se

Karumi 61 Nov 20, 2022
My own approach to what I think an Android MVVM project with Clean Architecture should look like with Dagger-Hilt as Dependency Injector engine

MVVM Project Hilt Introducción Este proyecto es mi visión particular, ni mejor ni peor (sólo una más) que cualquier otra aproximación a lo que yo enti

Antonio Fdez. Alabarce 7 Dec 16, 2022
Simple application showing wallets fetched from fake services

LittleWallet Resume Simple application showing wallets fetched from fake services. User can filter wallets by currency types and click to enter a deta

null 0 Nov 15, 2021
A basic template ecommerce application with payment integration made using Android Architechture componets

ShopIt ShopIt is a basic template ecommerce application with payment integration(RazorPay), made using Android Architechture componets and Material Co

Apurva Shukla 2 Nov 22, 2021
Torus CustomAuth integration samples for Android applications

CustomAuth Android Samples Examples of using Torus CustomAuth Android SDK. Usage Clone the repository and open with Android Studio Run the app, you'll

Minh-Phuc Tran 1 Dec 3, 2021
Android Open-Source Telematics App with Firebase© integration

Android Open-Source Telematics App with Firebase© integration Description This Telematics App is developed by Damoov and is distributed free of charge

null 0 Jan 14, 2022
Playground for Vault Integration

Vault Lab This is playground for spring-booter to test integrating with Vault the Hashi-Corp product. Secret-Engines that are available now: Transit :

Vandy Sodanheang 1 Apr 6, 2022
Example project for using the Selenium toolkit with Kotlin, Maven, TestNg and the config is managed via a property file.

Selenium-Java-Toolkit-TestNg-Playground This is the sample-Project and show you how to use the Selenium-Toolkit. The Selenium-Toolkit is a Java based

Selenium Consulting 0 Dec 15, 2021
Shreyas Patil 2.2k Jan 4, 2023
This is a work-in-progress (🔧️) ultraviolet index viewer app for demonstrating Instant Apps + Kotlin + Dagger + MVP

UV Index A simple ultraviolet index viewer app for demonstrating: Instant Apps + Kotlin + Dagger + MVP Built With Weatherbit as weather API Android In

Mustafa Berkay Mutlu 65 Oct 31, 2022
App built using Kotlin, Dagger Hilt, Room Database, Coroutines, Flow, AndroidX Glance, WorkManager, Coil etc.

An article sharing platform where you can personalize, subscribe to your favorite topics, get daily-read reminders, etc. App built using Kotlin, Dagger Hilt, Room Database, Coroutines, Flow, AndroidX Glance, WorkManager, Coil etc.

Kasem SM 484 Jan 3, 2023
Android Example project

Example project for the employers. I created this project for the employers because I often get demands about showing some of my code. Patterns: MVP C

null 0 Nov 21, 2021
An example project for configuring Rust with Java 18's Panama/jextract

rust-panama A template project for setting up both Rust and the Java 18 Panama Foreign Linker API (via jextract). How to Setup Clone the repo. Modify

Aidan 14 Jul 5, 2022
Showify is a my first simple ✅ Android application 📱 using DI, where I learn how to use dagger-hilt, retrofit2, mvvm, livedata, Requestly Interceptor

Showify is a my first simple ✅ Android application ?? using DI, where I learn how to use dagger-hilt, retrofit2, mvvm, livedata, Requestly Interceptor and so much more...

MOHIT GUPTA 1 Jun 21, 2022
A small application for working with the Github API, made as a practical task. GeekBrains, course of study: Popular libraries: RxJava 2, Dagger 2, Moxie.

GeekBrains_Course_AndroidOnKotlin_HW_My_Movie Домашнее задание к занятию №2-6 Студента GeekBrains Веремеенко Дмитрия Факультет: Android-разработки Кур

Dmitriy 3 Aug 24, 2021
Dagger-Hilt

DaggerHilt Dagger-Hilt in this Repo i have demonstrated the use of the following in android Kotlin Dagger2 Room Persistence Retrofit2 MVI / MVVM Archi

Mohamed Dekow 2 Apr 8, 2022