0

I'm using Dagger 2 with Gradle and have everything setup and code generation is working properly.

My build.gradle:

task wrapper(type: Wrapper) {
    gradleVersion = '2.11'
}

subprojects {
    apply plugin: 'java'

    repositories {
        mavenCentral()
    }

    dependencies {
        ... omitted as irrelevant to question ...

        compile 'com.google.dagger:dagger:2.0.2'
        compile 'com.google.dagger:dagger-compiler:2.0.2'
        compile 'javax.inject:javax.inject:1'
    }

}

My problem is that I am unable to resolve the classes and use them in my source, any solutions I've found are targeted towards Android which I am not using. How would I be able to resolve these generated classes as dependencies?

johnathenwhiter94
  • 124
  • 1
  • 3
  • 11

2 Answers2

0

I had a similar issue some time ago. In your case I would say that you need the apt plugin. Check this question where I explained how I resolved it

Community
  • 1
  • 1
Alberto S.
  • 7,409
  • 6
  • 27
  • 46
0

I fixed this issue by enabled annotation processing in my IDE as well as adding Dr. Pelocho's answer.

  • Apply this answer: https://stackoverflow.com/a/33445767/1787084 to your build.gradle

  • Add apply plugin: 'eclipse' in your build.gradle

  • Enable annotation processing to the apt directory created by the ltgt gradle apt plugin in Eclipse by navigating to project properties -> Java compiler -> Annotation processing -> Enable project specific settings -> Enable annotation processing

  • Change generated source directory to build/generated/source/apt/main to match the ltgt default directory

  • Click "OK" or "Apply"

This added the Dagger generated classes to my build path and classpath

Community
  • 1
  • 1
johnathenwhiter94
  • 124
  • 1
  • 3
  • 11