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
ToDo list is a sample project for save task and complete they. developed with Kotlin , Coroutins and Dagger-Hilt Dependency injection.

ToDo list is a sample project for save task and complete they. developed with Kotlin , Coroutins and Dagger-Hilt Dependency injection.

Seyyed Ali Tabatabaei 8 Dec 28, 2022
A full-stack application showing the power 💪 of KOTLIN. Entire android app + backend Apis written in Kotlin 🔥

Gamebaaz ?? A full-stack application showing the power ?? of KOTLIN. Entire android app + backend Apis written in Kotlin ?? Android Backend Jetpack Co

Sarnava Konar 85 Nov 17, 2022
Github-Api-Pagination-Example - Pagination 3 Example using Github Api

Github-Api-Pagination Pagination 3 Example using Github Api Tech Stack 100% Kotl

Anggoro Beno Lukito 2 Aug 22, 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
Integration of ONNX with Kotlin JS - Deep Learning running in the browser

Integration of ONNX with Kotlin JS - Deep Learning running in the browser

londogard 5 Jul 22, 2022
Android application showing list of Countries with National capital and flag.

Countries Android application showing list of Countries with National capital and flag. Implemented using Android MVVM architecture and used RxJava, D

Kartikay singh 1 Nov 28, 2021
SNS app showing nearby parks and forests

?? LittleForest Little Forest는 공원과 자연휴양림을 소개하고, 사진을 공유하는 안드로이드 SNS 어플리케이션입니다. 우리

hyobeom han 0 Dec 26, 2021
A beautiful app showing the use of a single recyclerview to display multiple views with motion layout and clean architecture

This app shows how to use a single recyclerview to build a beautiful multiple view layout (See image below) using clean architectural pattern

Ibrajix 62 Dec 26, 2022
Samples showing best practices for MIDI on Android.

MIDI Samples This repository contains a set of individual Android Studio projects to help you write apps using MIDI APIs. Android MIDI 2.0 API samples

Android 23 Dec 19, 2022
A simple sample showing the different types of notifications on Andoid

Notification example Simple notification. Expandable notification Progress notification Action button notification Notifications: MainActivity: Refs h

Saul Molinero 191 Nov 29, 2022
🏛 ThinkRchive Light Dark An app showing all details for various Lenovo Thinkpad models.

?? ThinkRchive Light Dark An app showing all details for various Lenovo Thinkpad models. Made to try out Jepack Compose for Android. This repo is a Mu

Thinkrchive 59 Dec 28, 2022
Akshaya Patra Donation App using Razorpay android integration

Akshaya Patra Donation App (razorpay-android-integration) Akshaya Patra Donation App using razorpay integration Dependency used : Razorpay : com.razor

Ayush Kumar Singh 1 Nov 25, 2021
This service provides first-class custom ROM integration for my Repainter app, which offers customizable dynamic theming for Android 12.

Repainter ROM integration This service provides first-class custom ROM integration for my Repainter app, which offers customizable dynamic theming for

Danny Lin 42 Jan 7, 2023
To Do List App is built in Kotlin using Material 3, Data Binding, Navigation Component Graphs, Room persistence library, Kotlin coroutines, LiveData, Dagger Hilt, and Notifications following MVVM Architecture.

ToDoListApp ToDoList App demonstrates modern Android development with Hilt, Coroutines, LiveData, Jetpack (Room, ViewModel), and Material 3 Design bas

Naman Garg 10 Jan 8, 2023
Instagram clone App in android using Kotlin, LiveData, MVVM, Dagger, RxJava and Retrofit.

Instagram-Project-in-android-with-MVVM-architecture Project from MindOrks Professional Bootcamp with self practice work and added some additional feat

Abhishek Solanki 3 Feb 28, 2022
A simple NewsApp built using Jetpack Compose, MVVM Architecture, Dagger Hilt and Kotlin Flow

NewsApp is simple App which uses NewsAPI to get top headlines for country you live in or you can search for a specific news. Focus of this app is to d

ElvisOperator 4 Aug 20, 2022
Example of a multimodule project following SOLID principles and MVVM, Hilt, Room, coroutines and testing.

MarvelCharacters David Ferrándiz Features Retrieve Marvel’s characters and show them in a grid. See more information about the character in a new scre

David Ferrandiz 2 Aug 22, 2022
Shreyas Patil 2.1k Dec 30, 2022