Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generated classes not found

Using Dagger2 and Kotlin, my component class implementations are not being generated when other calling code exists. When no calling code exists, the implementations are generated.

E.g.

val comp = DaggerMyComponent.create()

Causes the build to fail, DaggerMyComponent is not generated and thus cannot be found

// val comp = DaggerMyComponent.create()

The DaggerMyComponent class is generate and can be viewed on disk, the build succeeds.

I've tried Dagger 2.0.1, 2.0.2, 2.1-Snapshot, using Kotlin beta-1103. I can post my gradle file, source code, or stack trace if needed.

Has anyone encountered this issue before?

like image 306
Nathan Avatar asked Nov 12 '15 01:11

Nathan


People also ask

What is generated sources in Java?

It's a step in the build process that generates source files from other files, e.g. generating Java source files from XML schema files (JAXB). – Andreas.

What does Mvn generate sources do?

The “maven-source” plugin is used to pack your source code and deploy along with your project. This is extremely useful, for developers who use your deployed project and also want to attach your source code for debugging.


1 Answers

In your app's build file, make sure you added

kapt {
    generateStubs = true
}

some example projects can be found here

https://github.com/damianpetla/kotlin-dagger-example/tree/master/app https://github.com/burntcookie90/KotlinDaggerDataBinding

like image 161
MatthewFong Avatar answered Sep 20 '22 01:09

MatthewFong