[英]Dagger2 error: Kotlin: Unresolved reference: DaggerSOMETHINGComponent
I'm building a gradle project of Kotlin and Dagger2 which runs well half year ago in macOS: 我正在构建Kotlin和Dagger2的gradle项目,该项目在半年前在macOS中运行良好:
GitHub:Kotlin-Tutorials13 GitHub的:科特林-Tutorials13
you can get it by 你可以得到它
git clone https://github.com/enbandari/Kotlin-Tutorials.git
cd Kotlin-Tutorials/code/Kt13
you can open it in IntelliJ IDEA 您可以在IntelliJ IDEA中打开它
My building enviroment is listed as below: 我的建筑环境如下:
It tuens out an error: 它指出了一个错误:
C:\Users\xiang\IdeaProjects\Kotlin-Tutorials-master\code\Kt13\src\main\kotlin\net\println\kt13\Service.kt
Error:(3, 25) Kotlin: Unresolved reference: DaggerRESTFulComponent
Error:(19, 9) Kotlin: Unresolved reference: DaggerRESTFulComponent
So, I decompile RESTFulComponent.class
所以,我反编译
RESTFulComponent.class
the source file of it is RESTFulComponent.kt
它的源文件是
RESTFulComponent.kt
package net.println.kt13
import dagger.Component
import net.println.kt13.module.RetrofitModule
import retrofit2.Retrofit
import javax.inject.Singleton
/**
* Created by benny on 12/11/16.
*/
@Singleton
@Component(modules = arrayOf(RetrofitModule::class))
interface RESTFulComponent {
fun retrofit(): Retrofit
}
decompile RESTFulComponent.class
we get 反编译
RESTFulComponent.class
我们得到
// IntelliJ API Decompiler stub source generated from a class file
// Implementation of methods is not available
package net.println.kt13.module
@dagger.Module public final class RxAdapterModule public constructor() {
@javax.inject.Singleton @dagger.Provides public final fun adapter(): retrofit2.CallAdapter.Factory { /* compiled code */ }
}
The error result from annotation of dagger 's not working. 该错误是由于dagger的注释无效而导致的。
How can I fix this error? 如何解决此错误?
I use Ctrl+F9 to compile and this error arises。 我使用Ctrl + F9进行编译,并且出现此错误。
We should click View -> Tool Windows -> Gradle to open Gradle projects Window 我们应该单击查看 -> 工具窗口 -> Gradle打开Gradle项目窗口
Then click Tasks -> build -> build 然后单击任务 -> 构建 -> 构建
Ctrl+F9 isn't invoking gradle build
, we should use gradle build
in Gradle projects Window Ctrl + F9不调用
gradle build
,我们应该在Gradle项目窗口中使用gradle build
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.