본문 바로가기

안드로이드/오류해결

[안드로이드/Android] dataBinding 오류

반응형


에러코드


 Error:[kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: failure, see logs for details.

Exception while handling step android.databinding.annotationprocessor.ProcessExpressions@3ea50887 javax.xml.bind.UnmarshalException

 - with linked exception:

[com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 1은(는) 1바이트 UTF-8 시퀀스에 대해 부적합한 바이트입니다.]


Histroy

  • 2018.12.17 : 초안 작성
  • 2019.04.23 : string.xml 여백



필자는 작업을 맥과 윈도우에서 상황에따라 바꿔가며 작업을 진행하는데, 맥북에서 사용하던 프로젝트를 윈도우로 옮겼을때 해당 에러가 발생했습니다. 'javax.xml.bind.UnmarshalException' 에러는 databinding을 사용하여 xml에서 string 값들을 조작할때 발생합니다. 아래 '스트라이크' 텍스트를 string.xml 로 옮겨서 해당 리소스를 로드하는 방법으로 오류를 해결했습니다.

수정전

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{item.strike.toString+" 스트라이크"}'
android:textColor="@color/strike"
android:textSize="14dp"
tools:text="1스트라이크" />


수정후

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{item.strike.toString+@string/strike_text}'
android:textColor="@color/strike"
android:textSize="14dp"
tools:text="1스트라이크" />


데이터바인딩은 정말 좋은 라이브러리지만..

작게 속썩이는게 많은 느낌입니다.


ps.

string.xml로 옮기실때 텍스트 앞뒤로 빈공간을 추가하고 싶으신 경우 '&#160;' 를 사용하셔야 합니다.

ex) 

<string name="baseic">&#160;기준</string>



해당 포스팅은 지극히 주관적인 내용으로 저자의 복기 목적으로 작성된 것이고, 내용에대해 수정이나 추가 요청은 언제든 환영합니다. 




반응형