0

I'm trying to learn Dagger. But when I try to create a new object through a component with a Dagger prefix, it tells me "cannot resolve symbol". Searching online, apparently I'm supposed to include something like this:

dependencies {

    compile files('libs/dagger-2.8.jar')
    compile files('libs/dagger-compiler-2.8.jar')
    ...

    apt 'com.google.dagger:dagger-compiler:2.8' code generation
}

But this is the error I get:

Error:Cause: unable to find valid certification path to requested target

It seems to recognize the apt command but not 'com.google.dagger:dagger-compiler:2.8'. Anyone know how to solve this..?

Thanks

Harambe
  • 1
  • 2

2 Answers2

2

This is an issue with Gradle, not with Dagger. When you add the dependency on Dagger-2 to the build.gradle and build, Gradle will attempt to download the new dependencies for your project.

Hence the error you are getting when Gradle attempts to download Dagger 2:

The valid certification path to requested target

This seems to be caused by workplace proxies if they 'man-in-the-middle' with their own self-signed SSL certificates. You can try exporting the certificates from your workplace into the Java environment following the instructions here and if that doesn't work, there are some answers here.

If that fails, perhaps you can download the jars from Maven Central or simply run the build while connected to a network that is not behind a hostile proxy.

David Rawson
  • 20,912
  • 7
  • 88
  • 124
1

See the dagger docs here: https://github.com/google/dagger

Gradle should be like so:

// Add Dagger dependencies
dependencies {
  compile 'com.google.dagger:dagger:2.8'
  annotationProcessor 'com.google.dagger:dagger-compiler:2.8'
}
Rich Luick
  • 2,354
  • 22
  • 35