简体   繁体   English

使用 jar 文件的 Gradle 的 AnnotationProcessor 依赖项

[英]AnnotationProcessor dependency for Gradle using a jar file

I am integrating dagger in my project and I am having this issue.我正在我的项目中集成匕首,我遇到了这个问题。

I want to add jar dependencies instead of我想添加 jar 依赖项而不是

`annotationProcessor "com.google.dagger:dagger-compiler:2.41"`

like below像下面

annotationProcessor files('libs/dagger-compiler-2.41.jar') but when I compile, it gives me error annotationProcessor files('libs/dagger-compiler-2.41.jar')但是当我编译时,它给了我错误

Execution failed for task ''.任务“”执行失败。

dagger/spi/shaded/androidx/room/compiler/processing/javac/JavacBasicAnnotationProcessor Caused by: java.lang.NoClassDefFoundError: dagger/spi/shaded/androidx/room/compiler/processing/javac/JavacBasicAnnotationProcesso dagger/spi/shaded/androidx/room/compiler/processing/javac/JavacBasicAnnotationProcessor 引起:java.lang.NoClassDefFoundError: dagger/spi/shaded/androidx/room/compiler/processing/javac/JavacBasicAnnotationProcesso

It is working with other jar daggger dependency but not with AnnotationProcessor.它与其他 jar 匕首依赖项一起使用,但不适用于 AnnotationProcessor。 When I use annotationProcessor "com.google.dagger:dagger-compiler:2.41" everything works fine.当我使用annotationProcessor "com.google.dagger:dagger-compiler:2.41"一切正常。

implementation files('libs/javax.inject-1.jar')
implementation files('libs/dagger-2.41.jar')
implementation files('libs/dagger-producers-2.41.jar')

After so much of research and hit and trial and lot of trying I was able to integrate daggger to my Project in gradle as well as in android MK.经过如此多的研究、打击、试验和大量尝试,我能够将 dagger 集成到我的 gradle 以及 android MK 的项目中。

For Gradle: Worked for both API 28 and 30对于 Gradle:适用于 API 28 和 30

//Dagger Dependencies
annotationProcessor files('libs/dagger-compiler-2.42.jar')
implementation files('libs/dagger-2.42.jar')
annotationProcessor files('libs/dagger-2.42.jar')
annotationProcessor files('libs/jsr305-3.0.2.jar')
annotationProcessor files('libs/dagger-producers-2.42.jar')
annotationProcessor files('libs/dagger-spi-2.42.jar')
annotationProcessor files('libs/google-java-format-1.5.jar')
annotationProcessor files('libs/failureaccess-1.0.1.jar')
annotationProcessor files('libs/guava-31.0.1-jre.jar')
annotationProcessor files('libs/javapoet-1.13.0.jar')
implementation files('libs/javax.inject-1.jar')
annotationProcessor files('libs/javax.inject-1.jar')
annotationProcessor files('libs/incap-0.2.jar')
annotationProcessor files('libs/checker-compat-qual-2.5.5.jar')
annotationProcessor files('libs/kotlin-stdlib-1.6.10.jar')
annotationProcessor files('libs/kotlin-stdlib-jdk8-1.5.32.jar')
annotationProcessor files('libs/kotlinx-metadata-jvm-0.4.2.jar')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM