dagger: error: cannot find symbol @Generated( ^
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.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 23
- Comments: 32
Commits related to this issue
- Update build.gradle Remove kapt workaround since per https://github.com/google/dagger/issues/1449#issuecomment-595238637 this should be fixed in the version of Kotlin that we're now using. — committed to oppia/oppia-android by BenHenning 3 years ago
- Update app/build.gradle Add explicit javax annotations dependency per https://github.com/google/dagger/issues/1449#issuecomment-588277905. — committed to oppia/oppia-android by BenHenning 3 years ago
- Update data/build.gradle Add explicit javax annotations dependency per https://github.com/google/dagger/issues/1449#issuecomment-588277905. — committed to oppia/oppia-android by BenHenning 3 years ago
- Update domain/build.gradle Add explicit javax annotations dependency per https://github.com/google/dagger/issues/1449#issuecomment-588277905. — committed to oppia/oppia-android by BenHenning 3 years ago
- Update testing/build.gradle Add explicit javax annotations dependency per https://github.com/google/dagger/issues/1449#issuecomment-588277905. — committed to oppia/oppia-android by BenHenning 3 years ago
- Update utility/build.gradle Add explicit javax annotations dependency per https://github.com/google/dagger/issues/1449#issuecomment-588277905. — committed to oppia/oppia-android by BenHenning 3 years ago
- Partially fix #2844: force Gradle tests to run on JDK 9 in CI (#2845) * Update build.gradle Remove kapt workaround since per https://github.com/google/dagger/issues/1449#issuecomment-595238637 thi... — committed to oppia/oppia-android by BenHenning 3 years ago
- Partially fix #2844: force Gradle tests to run on JDK 9 in CI (#2845) * Update build.gradle Remove kapt workaround since per https://github.com/google/dagger/issues/1449#issuecomment-595238637 thi... — committed to techjd/oppia-android by BenHenning 3 years ago
- Partially fix #2844: force Gradle tests to run on JDK 9 in CI (#2845) * Update build.gradle Remove kapt workaround since per https://github.com/google/dagger/issues/1449#issuecomment-595238637 thi... — committed to techjd/oppia-android by BenHenning 3 years ago
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.In Kotlin 1.3.70 it’s fixed
Yes, that is the workaround for now. I have filed https://youtrack.jetbrains.com/issue/KT-32804 (FINALLY).
I’ll link the bug here once I file it.
On Fri, Mar 22, 2019 at 11:15 AM ColtonIdle notifications@github.com wrote:
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:
@pdecat No, it is not. I still see the problem on a project with
1.3.61
🤷♂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.
To run itself as it’s a Java application. Not to run your code.
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"
andfixed the issue. Btw the issue doesn’t exist with OpenJdk 11