Windows環境でAndroidのDataBindingを使ってる時にMalformedByteSequenceExceptionが出た時の対処方法
1908 ワード
Windows環境でAndroidのDataBindingを使ってると以下のようなエラーが出ることがある。
Error:com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: 3バイトのUTF-8シーケンスのバイト3が無効です
これはレイアウトXMLで直接日本語を使ってるいると起きる。
例えばこんな感じの記述
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="hogeFlag"
type="Boolean"/>
</data>
....
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
text="@{hogeFlag ? `だめな日本語` : `foo`}"/>
</layout>
こういう時は素直にstringリソースを使うようにすれば正しく動く
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
text="@{hogeFlag ? @string/hoge : @string/foo}"/>
一時的なものとして入れてたら思わぬ問題が起きてしまった。
Author And Source
この問題について(Windows環境でAndroidのDataBindingを使ってる時にMalformedByteSequenceExceptionが出た時の対処方法), 我々は、より多くの情報をここで見つけました https://qiita.com/chuross/items/562a53a8b2ad15638de0著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .