java.lang.RuntimeException: Unable to start activity ComponentInfo{com.butterknife/com.butterknife.MainActivity}: java.lang.IllegalStateException: Required view 'button' with ID 2131427415 for field 'button' was not found. If this view is optional add '@Nullable' (fields) or '@Optional' (methods) annotation.
Caused by: java.lang.IllegalStateException: Required view 'button' with ID 2131427415 for field 'button' was not found. If this view is optional add '@Nullable' (fields) or '@Optional' (methods) annotation.
위 같이 오류가 뜹니다
자바 파일은
public class MainActivity extends AppCompatActivity {
@BindView(R.id.button)
Button button;
@BindView(R.id.title)
TextView title;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
title.setText("tete");
}
}
요렇게 되어있고요
ButterKnife 사이트에서
dependencies {
compile 'com.jakewharton:butterknife:8.5.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
}
요거 추가하고
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.jakewharton:butterknife-gradle-plugin:8.5.1'
}
}
요것도 추가
apply plugin: 'com.android.library'
apply plugin: 'com.jakewharton.butterknife'
이 plugin 첫번째 꺼는 추가가 안되고 2번째 꺼는 추가가 되더라고요 일단 2번째꺼만 추가를 하고
싱크하고 실해했더니 저런 오류가 뜹니다 도대체 왜그럴까요?????