gpt4 book ai didi

android - 由于gradle问题,如何修复 “Unable to load class ' Dagger 。

转载 作者:行者123 更新时间:2023-12-03 05:06:28 24 4
gpt4 key购买 nike

我目前正在使用Android Studio 3.4.2开发android应用程序(最低API级别21)。当我尝试同步我的gradle时(我正在添加 Dagger 依赖项),我似乎失去了互联网连接,因此导致gradle损坏。

到目前为止,我已经尝试删除gradle和IDE缓存,删除并重新下载整个gradle,重新启动IDE,使用本地gradle,重新启动PC并重新导入项目...

我实际上在这个问题上尝试了每个答案:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

我的build.gradle:

...
implementation 'com.google.dagger:dagger:2.24'
annotationProcessor 'com.google.dagger:dagger-compiler:2.7'
implementation 'com.google.dagger:dagger-android:2.15'
annotationProcessor 'com.google.dagger:dagger-android-processor:2.24'

遵循所有规定的说明几个小时后,我仍然收到相同的错误消息:
Unable to load class 'dagger.Multibindings'.
Possible causes for this unexpected error include:
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)

The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.
Stop Gradle build processes (requires restart)

Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

由于删除以下行后实际上可以添加新的依赖项,因此我怀疑问题实际上可能是由 Dagger 引起的,因为在尝试同步新的 Dagger 依赖项时,gradle被中断了:
annotationProcessor 'com.google.dagger:dagger-android-processor:2.24'

这个问题确实令人困惑,我需要您的帮助!
先感谢您。

最佳答案

//添加Dagger依赖项

dependencies {
implementation 'com.google.dagger:dagger:2.x'
annotationProcessor 'com.google.dagger:dagger-compiler:2.x'
}

依赖示例:
implementation 'com.google.dagger:dagger-android:2.20'
implementation 'com.google.dagger:dagger-android-support:2.20' // if you use the support libraries
annotationProcessor 'com.google.dagger:dagger-android-processor:2.20'
annotationProcessor 'com.google.dagger:dagger-compiler:2.20'

关于android - 由于gradle问题,如何修复 “Unable to load class ' Dagger 。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57532402/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com