위 에러의 Unable to start activity ComponentInfo
는 말 그대로 액티비티가 시작될 때 화면을 로드하지 못할 경우 발생하는 에러이다.
[검색 결과]
등등... 여러 이유가 있다.
public class MainActivity extends AppCompatActivity {
@BindView(R.id.rv_repos)
RecyclerView recyclerView;
...
@Override
protected void onCreate(Bundle savedInstanceState) {
ButterKnife.bind(this);
...
recyclerView.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false));
...
}
}
앱 실행을 하면 Unable to start activity ComponentInfo
에러와 함께 recyclerView 에서 NPE가 발생했다고 알려준다.
그래서 리사이클러뷰쪽만 겁나 보고있었다..
build.gradle에서 kotlin-kapt
플러그인을 추가한 적이 있었는데.. (문제의 이유)
Kotlin을 사용하는 경우에는 annotationProcessor
를 kapt
로 바꿔줘야한다.
ButterKnife
dependencies {
...
implementation 'com.jakewharton:butterknife:10.2.3'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3'
}
dependencies {
...
implementation 'com.jakewharton:butterknife:10.2.3'
kapt 'com.jakewharton:butterknife-compiler:10.2.3'
}