我在我的项目中收到了这个警告。我正在学习使用 IntelliJ IDEA 作为我的 IDE。
这是带有警告的代码:
@InjectView(R.id.button)
private Button loginBtn;
完整消息如下:
Binding annotation
@InjectView(R.id.button)
without@Inject
declared less... (Ctrl+F1)This inspection reports binding annotations on fields or parameters without a matching @Inject annotation.
Such annotations will be ignored by Guice. Powered by GuiceyIDEA
我不明白它要我做什么。
我在该字段上添加了一个 @Inject
注释,警告确实消失了,但该应用程序无法运行。
那么我应该怎么做才能修复这个警告呢?
谢谢。
最佳答案
几个月以来我们一直在使用 android studio,但我从未遇到过此类问题。
但是请确保如果你在 android activity 中使用 butterknife 然后使用
@InjectView(R.id.button)
private Button loginBtn;
别忘了调用它
ButterKnife.inject(this);
在 Activity 类中 setContentView 之后
希望对你有帮助!!
关于java - 绑定(bind)注解@InjectView 没有@Inject 声明的警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29429919/