android数据绑定错误:任务':app:dataBindingProcessLayoutsDebug'的执行失败 [英] android databinding error:Execution failed for task ':app:dataBindingProcessLayoutsDebug'
问题描述
我在我们项目中的伙伴使用android databinding。在我的电脑中有错误,但在他的mac中没有错误。我无法解析此程序。请帮助!!
是我的构建包:
my partner in ours' project use android databinding.in my pc had error,but in his mac not error.i cant resolve this program.please help!! it's my build gradle:
dataBinding {
enabled = true
}
第一个构建的androidstudio说
the first build androidstudio say
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence.
然后我使用UTF-8重新保存XML文件,但诞生了一个新问题。 p>
then i resave XML file use UTF-8.but a new problem birth.like this:
:app:dataBindingProcessLayoutsDebug
line 1:0 mismatched input '?' expecting {COMMENT, SEA_WS, '<', PI}
Error:Execution failed for task ':app:dataBindingProcessLayoutsDebug'.
java.lang.NullPointerException(无错误消息)
java.lang.NullPointerException (no error message)
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bind="http://schemas.android.com/apk/res-auto">
<data>
<import type="android.view.View"/>
<import type="com.vomoho.vomoho.common.Utils"/>
<variable name="postDetail" type="com.vomoho.vomoho.entity.PostDetail" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">
<include
android:id="@+id/top"
layout="@layout/dt_item_postdetail_top"
bind:postDetail="@{postDetail}"/>
<ImageView
android:id="@+id/img1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="8dp"
android:scaleType="centerCrop"
android:visibility="@{Utils.getPostType(postDetail.picList) == 0 ? View.GONE : View.VISIBLE}"
bind:imageUrl="@{postDetail.picList.size() > 0 ? postDetail.picList.get(0) : ``}"
bind:width="@{Utils.getPostImgWidth(Utils.getPostType(postDetail.picList))}"
bind:height="@{Utils.getPostImgHeight(Utils.getPostType(postDetail.picList))}" />
<include
android:id="@+id/bottom"
layout="@layout/dt_item_postdetail_bottom"
bind:postDetail="@{postDetail}"/>
</LinearLayout>
</layout>
推荐答案
我遇到了同样的问题,终于找到了解决方案。
我发现有这样写的布局xml文件:
I have the same problem, and I finally found the solution.
I found that there is a layout xml file was written like that:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text='@{"年龄 " + String.valueOf(user.age)}'/>
然后我不能在Windows平台上构建,但可以在Mac OS X平台上构建它是Android数据绑定的一个错误,因此我的临时解决方案是:
不要在 @ {}
部分中写入任何字符,而应使用字符串引用。 (就我而言,它替换为 android:text ='@ {@ string / age_text + String.valueOf(user.age)}'/>
)
希望对您有帮助。
and then it cannot built on Windows platform, but it can built on Mac OS X platform, I think its a bug of Android Data Binding, so my temporary solution is:
don't writing any character in @{}
section, use string reference instead. (in my case, its replace as android:text='@{ @string/age_text + String.valueOf(user.age) }'/>
)
hope it helps you.
这篇关于android数据绑定错误:任务':app:dataBindingProcessLayoutsDebug'的执行失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!