Androidentrypoint不使用AbstractComposeView
我正在使用匕首进行依赖注入。在我的AbstractComposeView中,我需要访问Compososable功能中的ViewModel。为此,我必须用@androidentrypoint注释我的AbstractComposeView,因为我的组合是AbstractComposeView的一部分(用于使用@androidentrypoint的服务中)。但是我遇到了这个错误。
error: [Hilt]
The base class, 'androidx.compose.ui.platform.AbstractComposeView', of the @AndroidEntryPoint,
'com.qwillio.vendi.keyboard.presentation.KeyboardView',
contains a constructor with default parameters.
This is currently not supported by the Gradle plugin. Either specify the
base class as described at https://dagger.dev/hilt/gradle-setup#why-use-the-plugin
or remove the default value declaration.
[Hilt] Processing did not complete. See error above for details.
[Hilt]
这是我的AbstractComposeView
@AndroidEntryPoint
class KeyboardView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : AbstractComposeView(context, attrs, defStyleAttr) {
private var keyboardActionListener: OnKeyboardActionListener? = null
fun setOnKeyboardActionListener(keyboardActionListener: OnKeyboardActionListener) {
this.keyboardActionListener = keyboardActionListener
}
@Composable
override fun Content() {
Vendiboard {
keyboardActionListener?.onKeyboardAction(it)
}
}
}
I am using DaggerHilt for dependency injection. In my AbstractComposeView, I need to access the ViewModel in a Composable function. To do that I have to annotate my AbstractComposeView with @AndroidEntryPoint, since my Composable is part of the AbstractComposeView (which is being used in a Service with @AndroidEntryPoint). but I am getting this error.
error: [Hilt]
The base class, 'androidx.compose.ui.platform.AbstractComposeView', of the @AndroidEntryPoint,
'com.qwillio.vendi.keyboard.presentation.KeyboardView',
contains a constructor with default parameters.
This is currently not supported by the Gradle plugin. Either specify the
base class as described at https://dagger.dev/hilt/gradle-setup#why-use-the-plugin
or remove the default value declaration.
[Hilt] Processing did not complete. See error above for details.
[Hilt]
This is my AbstractComposeView
@AndroidEntryPoint
class KeyboardView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : AbstractComposeView(context, attrs, defStyleAttr) {
private var keyboardActionListener: OnKeyboardActionListener? = null
fun setOnKeyboardActionListener(keyboardActionListener: OnKeyboardActionListener) {
this.keyboardActionListener = keyboardActionListener
}
@Composable
override fun Content() {
Vendiboard {
keyboardActionListener?.onKeyboardAction(it)
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论