[안드로이드 프로그래밍] - 안드로이드 스튜디오 오류 : Caused by: android.view.InflateException: Binary XML file line #,Caused by: java.lang.NoSuchMethodException:<init> [class android.content.Context, interface android.util.Attribute..
안드로이드 프로그래밍
안드로이드 스튜디오 오류
Caused by: android.view.InflateException: Binary XML file line #
Caused by: java.lang.NoSuchMethodException:
<init> [class android.content.Context, interface android.util.AttributeSet]
안드로이드 스튜디오로 프로그래밍 하던 중,
라이브러리 추가하면서 한~참 충돌나는거 잡던 중 생긴 오류
(나중에 보니 이오류는 날 필요도 없는 오류였었다 ㄸㄹㄹ)
java.lang.RuntimeException: Unable to start activity ComponentInfo
Caused by: android.view.InflateException: Binary XML file line #203: Error inflating class 패키지명.클래스명
Caused by: java.lang.NoSuchMethodException: <init> [class android.content.Context, interface android.util.AttributeSet]
그렇게 구글님과 다시 심도있는 대화를 해본 결과, 원인은 두가지!
1. 클래스 파일 경로 문제
2. 생성자 문제
둘다 복합적인 거라서 클래스 파일 경로 다시 확인하고,
생성자를 추가 생성하였다
public class TestEdit extends View {
public TestEdit (Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
}
이렇게 하나의 생성자만 있던 것을
아래와 같이 추가해주니 오류 해결 !
public class TestEdit extends View {
public TestEdit (Context context, AttributeSet attrs) {
super(context, attrs);
}
public TestEdit (Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
}
댓글 영역