Binary XML file line #1: Error inflating class
위 에러 정말 포괄적인 에러 지요.
그냥 간단하게 xml에 있는 View들을 초기화 하는데 에러가 발생 한다!!
그 에러는 2가지 형태로 축약하시면 될듯 합니다. (제경험상)
1. xml 값을 잘못 넣었다.
예를 들어 drawable 넣을 자리에 dimen 값을 넣은 것과 같은 것입니다.
<TextView
android:id="@+id/send_time_"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:background="15dp"
android:textColor="@color/_8F8F8F"
android:layout_gravity="bottom"
android:textSize="@dimen/_9sp"
android:text="22:23"
/>
2. CustomView가 있을 경우, 생성자 함수를 제대로 만들어주지 않았다.
이 이유때문에 전 거의 2시간을 화를 참으며 에러를 찾고 있었죠.
전혀 잘못된 곳이 없다고 생각했으니깐요 (정말 초보적인 실수였음...)
아래 소스에서 머가 잘못 됐을까요?
public CustomView(Activity activity) {
this(activity, null);
}
public MessageListItemView(Activity activity, AttributeSet attrs) {
super(activity, attrs);
this.ringqticonNames = Arrays.asList(RINGQTICON_NAMES);
this.requestManager = Glide.with(mContext);
}
예 맞습니다. activity를 Context로 바꿔야 합니다.
CustomView 생성자는 매개변수가 Activity가 아니라 Context로 지정되어 있거든요.
이 이유 때문에.. 괜히 쓸데 없이 xml만 뒤지고 다른 원인을 찾아다녔네요.
혹시 저같은 실수 하시는 분이 계실까봐 올립니다.
참고하세요.
출처: https://gogorchg.tistory.com/entry/Android-Binary-XML-file-line-1-Error-inflating-class [항상 초심으로]
'App > etc' 카테고리의 다른 글
No such algorithm: ECDSA for provider BC (0) | 2019.07.25 |
---|---|
Error PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 12500: , null) (0) | 2019.07.01 |
안드로이드 http 통신오류 (1) | 2019.05.17 |
Exception while doing past iteration backup: Source (0) | 2019.03.25 |
Error:(1, 1) error: illegal character: '\ufeff' (0) | 2018.11.12 |