I want to use Java 11, and I use many Dependencies including dagger as well
// Dagger
implementation "com.google.dagger:dagger:$daggerVersion"
implementation "com.google.dagger:dagger-android:$daggerVersion"
implementation "com.google.dagger:dagger-android-support:$daggerSupportVersion"
kapt "com.google.dagger:dagger-android-processor:$daggerSupportVersion"
kapt "com.google.dagger:dagger-compiler:$daggerCompilerVersion"
Now, when I run the project, I get this error:
/app/dagger/module/ActivityModule_ProvideStatsActivityViewModelFactory.java:6: error: package javax.annotation.processing does not exist
import javax.annotation.processing.Generated; import javax.annotation.processing.Generated;
^
After searching and implementing many answers still not able to solve this error.
I tried to add all step by step and together also.
implementation('javax.xml.bind:jaxb-api:2.3.1')
implementation('javax.activation:activation:1.1')
implementation('org.glassfish.jaxb:jaxb-runtime:2.3.2')
implementation "jakarta.xml.bind:jakarta.xml.bind-api:2.3.2"
implementation "org.glassfish.jaxb:jaxb-runtime:2.3.2"
implementation 'javax.xml.bind:jaxb-api:2.3.1'
implementation 'javax.annotation:javax.annotation-api:1.3.2'
kapt 'javax.annotation:javax.annotation-api:1.3.2'
compileOnly 'org.glassfish:javax.annotation:10.0-b28'
As per stated over this answer , root cause of the issue is that the file Generated.java was not found while using code generation on JDK 9+
Solution is to either use this dependency: https://github.com/pengrad/jdk9-deps which is compileOnly dependency or else use the solution as per following:
Create package under src/main (project source)
src/main/javax.annotation.processing in project source
Put below file content under the created package:
Generated.java
package javax.annotation.processing; public @interface Generated { String[] value(); String date() default ""; String comments() default ""; }
This will resolve the issue for dagger during compilation in android projects.
error: package javax.annotation.processing does not exist
import javax.annotation.processing.Generated; import javax.annotation.processing.Generated;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.