2016-10-05 3 views
2
내가 만들 때마다 때 재 구축, 깨끗하고, 실행, 데이터는 안드로이드 스튜디오 프로젝트에 라이브러리 바인딩 사용하고

등 나는 다음과 같은 오류 얻을 :안드로이드 데이터 바인딩 XML 오류

:app:processDebugResources AGPBI: 

{"kind":"error","text":"Error parsing XML: duplicate attribute","sources": [{"file":"C:\\Users\\lucia.beltran\\Desktop\\Picho\\Projects\\Personal\\ improved-tribble\\ImprovedTribble\\app\\build\\intermediates\\data-binding-layout-out\\debug\\ layout\\task_list_item.xml","position":{"startLine":16}}],"original":"","tool":"AAPT"} 

C:\Users\lucia.beltran\Desktop\Picho\Projects\Personal\improved-tribble\ImprovedTribble\app\build\intermediates\data-binding-layout-out\debug\layout\task_list_item.xml:17: error: Error parsing XML: duplicate 

FAILED 

FAILURE: Build failed with an exception. 

* What went wrong: Execution failed for task ':app:processDebugResources'. 
> com.android.ide.common.process.ProcessException: Failed to execute aapt 

* Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 

BUILD FAILED 

Total time: 3.826 secs 

내 레이아웃은 다음과 같이

<layout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <data> 
     <variable 
      name="task" 
      type="com.pichardo.improvedtribble.models.Task" /> 
    </data> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="horizontal"> 

    </LinearLayout> 

</layout> 

그리고 Gradle을 콘솔 말한다 바인딩 파일의 레이아웃과 같다 :

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" android:tag="layout/task_list_item_0" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> 

</LinearLayout> 

I 중복 속성을 가져 오지 만 왜 충돌이 발생하는지 알지 못합니다.

나는 this question을 읽었지만, 내 build.gradle 파일에는 그런 것이 없습니다.

제안 사항?

+0

소스 코드 청크의 형식을 올바르게 지정하려면 Ctrl + K 또는 Cmd + K를 사용해야합니다. –

답변

4

시도가 안드로이드를 제거하려면 : layout_width안드로이드 : layout_height = "match_parent"레이아웃 태그 여기

<layout xmlns:android="http://schemas.android.com/apk/res/android"> 

    <data> 
     <variable 
      name="task" 
      type="com.pichardo.improvedtribble.models.Task" /> 
    </data> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="horizontal"> 

    </LinearLayout> 

</layout> 
+0

고마워요 그 사람 –

+0

브로치에 오신 것을 환영합니다 ... –

+0

그래, 내가 왜 알아 내지 못했는지 모르겠어, 고마워 –

1

에서의 내 편집 됨 실제 코드 :

<?xml version="1.0" encoding="utf-8"?> 
<layout 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
> 

    <data> 
     <variable 
      name="MyDTO" 
      type="com.example.MyDTO" 
     /> 
    </data> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     tools:mContext="com.example.MyActivity" 
    > 

모든 네임 스페이스해야 바깥 쪽 레이아웃 태그에 있어야합니다. 삭제가 도움이되지 않았습니다.

+0

"모든 네임 스페이스는 외부 레이아웃 태그에 있어야합니다."- 그렇습니다. 프로젝트는 컴파일되지 않을 것입니다. –