Building via Android Studio works fine, but if I call
./gradlew build
I get
error: cannot find symbol
@Generated(
^
all over the place. I'm using the latest version of dagger. My android project is set to Java 8 source. Calling java --version in my terminal tells me I have java 9 (which I'm not sure how, but I that's besides the point). Any ideas what I should be doing? I've seen a bunch of mixed answers on stackoverflow, but adding a dependency feels weird. My system being on java 9 doesn't make sense to me because I though Android Studio bundles it's own version of the JDK.
but I that's besides the point
It isn't. This is the cause. Dagger uses https://github.com/google/auto/blob/master/common/src/main/java/com/google/auto/common/GeneratedAnnotations.java#L54-L61 to pick which annotation to use which picks the wrong one for Android.
Android Studio bundles it's own version of the JDK
To run itself as it's a Java application. Not to run your code.
Hm. I use sdkman. I guess I should easily be able to set my default back to java 8 and this should go away?
Are you using kapt? I think this is a kapt bug where it doesn't propagate the source version correctly.
I am indeed. Let me know what you think I should do, since I'm still a little confused. I'm assuming that I should just install the latest version of JDK 8 (or do I just need java8 runtime and not JDK) and set it as my system default.
You'll need to use JDK 8 to build until the kapt bug is fixed. I'll work on
creating a sample and reporting it today.
On Fri, Mar 22, 2019 at 10:46 AM ColtonIdle notifications@github.com
wrote:
I am indeed. Let me know what you think I should do, since I'm still a
little confused. I'm assuming that I should just install the latest version
of JDK 8 (or do I just need java8 runtime and not JDK) and set it as my
system default.—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
https://github.com/google/dagger/issues/1449#issuecomment-475648705, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAEEEe5JVbF45rejJiu1IJGMiinfVgHiks5vZOy8gaJpZM4cDs3Z
.
Just as an aside. Who manages kapt? Is that the jetbrains team or AS team? I'm just curious what version number I'll have to increment in the future to see if this is fixed.
JetBrains
On Fri, Mar 22, 2019 at 11:00 AM ColtonIdle notifications@github.com
wrote:
Just as an aside. Who manages kapt? Is that the jetbrains team or AS team?
I'm just curious what version number I'll have to increment in the future
to see if this is fixed.—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
https://github.com/google/dagger/issues/1449#issuecomment-475654401, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAEEEX5-EgOS8r_jDflVA9UCVBPz8wpYks5vZPAkgaJpZM4cDs3Z
.
Got it. I'll keep my eyes out for a kotlin plugin update. Thank you
I'll link the bug here once I file it.
On Fri, Mar 22, 2019 at 11:15 AM ColtonIdle notifications@github.com
wrote:
Got it. I'll keep my eyes out for a kotlin plugin update. Thank you
—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
https://github.com/google/dagger/issues/1449#issuecomment-475660211, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAEEERcs15GnBlMjo852h7eLEUX85jzkks5vZPOqgaJpZM4cDs3Z
.
Just as a heads up to everyone. I removed JDK 9 from my machine following oracles instructions here:
https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html#A1096903
And this error did go away. Even though I have sdkman installed it seems like 9 was installed not using sdkman. Not really sure. /shruggie
I have installed sdkman herer: https://sdkman.io/usage#installdefault, downgraded java version from 11 to 8 and this error did go away. That way it worked for me.
Is the bug filled? Maybe this project works as a sample project to demostrate the error: https://github.com/BraisGabin/daggerprocessorwrapper/tree/kotlin
I'll link the bug here once I file it.
…
On Fri, Mar 22, 2019 at 11:15 AM ColtonIdle @.*> wrote: Got it. I'll keep my eyes out for a kotlin plugin update. Thank you — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#1449 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEERcs15GnBlMjo852h7eLEUX85jzkks5vZPOqgaJpZM4cDs3Z .
@JakeWharton Did you end up filing this bug? Do you happen to have YouTrack link for it?
@RiteshAdulkar downgrading as you suggested worked 👍. Please fix your https://sdkman.io/usage#installdefault link. It is pointing to something else for now.
I managed to work around this on a JDK 11 install by adding the following to the bottom of my affected modules' build.gradle files. I imagine it would work in a subprojects.afterEvaluate block in the top-level build.gradle too.
if (project.hasProperty('kapt')) {
// Reference for 'kapt' DSL: https://kotlinlang.org/docs/reference/kapt.html#java-compiler-options
kapt {
// we expect this closure to run over a org.jetbrains.kotlin.gradle.plugin.KaptExtension
javacOptions {
option("-source", "8")
option("-target", "8")
}
}
}
Yes, that is the workaround for now. I have filed https://youtrack.jetbrains.com/issue/KT-32804 (FINALLY).
Thanks Jake!
@JakeWharton any updates?
You can follow along on the Kotlin bug. It's a kapt problem.
We should close this bug, actually. @ronshapiro
Upgrading from kotlin 1.3.50 to 1.3.60 resolves this issue with Java 11.
@pdecat No, it is not. I still see the problem on a project with 1.3.61 🤷♂
~Maybe a regression with 1.3.61?~
It worked for me with 1.3.60, see https://github.com/home-assistant/home-assistant-android/pull/204
And still works now with 1.3.61, https://github.com/home-assistant/home-assistant-android/pull/275/files#diff-c197962302397baf3a4cc36463dce5eaR4
JDK13 and JDK11 still gives me this problem and the workaround doesn't work either. Using either Kotlin 1.3.61 or 1.3.60 with either Dagger 2.25.4 or 2.26. Cannot fix the issue.
The only workaround is downgrading to JDK8 which big time sucks.
@ber444 there was a separate fix for JDK 12+ in kapt that should be fixed in 1.3.70. You should really be filing these on the kotlin issue tracker rather than here’s as dagger is just doing what kotlin tells it the source version is
Can confirm that everything is working with Kotlin 1.3.70 EAP using JDK11 (https://travis-ci.com/G00fY2/DeveloperWidget/jobs/288908127).
@ber4444 with Kotlin 1.3.60 I had to add javax.annotation:javax.annotation-api as compile dependency to be able to compile on JDK11: https://youtrack.jetbrains.com/issue/KT-33050#focus=streamItem-27-3767288.0-0
So looks like this issue was fixed inside the 1.3.70 kapt.
The same issue with Oracle JDK 13 and 1.3.61. I can confirm that adding:
compileOnly "javax.annotation:javax.annotation-api:1.3.2"
and
kapt { javacOptions { option("--source", "8")
option("--target", "8") } }
fixed the issue. Btw the issue doesn't exist with OpenJdk 11
In Kotlin 1.3.70 it's fixed
Most helpful comment
I managed to work around this on a JDK 11 install by adding the following to the bottom of my affected modules' build.gradle files. I imagine it would work in a
subprojects.afterEvaluateblock in the top-level build.gradle too.