[英]Can you use Hilt in a Java-only Android project?
According to the official integration guide , you need to add根据官方集成指南,您需要添加
plugins {
id 'kotlin-kapt'
...
}
and和
dependencies {
implementation "com.google.dagger:hilt-android:{hilt_version}"
kapt "com.google.dagger:hilt-compiler:{hilt_version}"
}
to your build.grade
file.到您的
build.grade
文件。 However, when I do a gralde sync, I get the following error:但是,当我执行 gralde sync 时,出现以下错误:
Plugin [id: 'kotlin-kapt'] was not found in any of the following sources:
在以下任何来源中均未找到插件 [id: 'kotlin-kapt']:
is it possible to use Dagger-Hilt in a pure java project?是否可以在纯 java 项目中使用 Dagger-Hilt? Or do you have to either use plain Dagger or use Kotlin?
或者你必须使用普通 Dagger 还是使用 Kotlin?
Yes, you can use the following instead of kotlin-kapt:是的,您可以使用以下内容代替 kotlin-kapt:
dependencies {
implementation "com.google.dagger:hilt-android:{hilt_version}"
annotationProcessor 'com.google.dagger:hilt-compiler:{hilt_version}'
}
plugins {
id 'dagger.hilt.android.plugin'
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.