Java @InjectView不';t在Android Studio上工作
我正在使用Android Studio构建一个Android应用程序。 我决定使用外部库来绘制自定义进度条 我对ButterKnife injection的库有问题。实际上,当我启动应用程序时,我会收到以下异常:Java @InjectView不';t在Android Studio上工作,java,android,view,code-injection,Java,Android,View,Code Injection,我正在使用Android Studio构建一个Android应用程序。 我决定使用外部库来绘制自定义进度条 我对ButterKnife injection的库有问题。实际上,当我启动应用程序时,我会收到以下异常: Process: com.robertot.timereport, PID: 16449 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.robertot.timereport/com
Process: com.robertot.timereport, PID: 16449
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.robertot.timereport/com.robertot.timereport.pages.MainActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.robertot.timereport/com.robertot.timereport.pages.MainActivity}: java.lang.RuntimeException: Unable to inject views for com.robertot.timereport.pages.MainActivity@64b1fd48
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2215)
相反,这是我的代码:
public class MainActivity extends FragmentActivity
{
@InjectView(R.id.google_progress)
GoogleProgressBar googleProgressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ButterKnife.inject(this); // CRASH HERE
//....
}
}
我做错了什么?检查您的
@InjectView
s的类型是否正确
我使用了
ImageView
而不是LinearLayout
你确定R.layout.activity\u main
包含谷歌进度条吗?如果是,您确定ProgressBar的id是google\u progress
?还要确保您没有丢失+
。是的!!这就是问题所在!!google_进度是在一个自定义的操作栏布局中,我在主帖子的代码下初始化了它。谢谢!!:)