Coder Social home page Coder Social logo

kotlin-dagger-example's Introduction

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.

kotlin-dagger-example's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kotlin-dagger-example's Issues

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.

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?

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?

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.

[Question] Annotation Processing

There were rumors, that annotation processing doesn't work in Kotlin. But I see, that your example perfectly works. How is it possible?

NotNull

Is there any reason you don't use Delegates.notNull()?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.