Android Databling xml duplicate attribute

Recentemente, comecei a desenvolview uma aplicação Android que usa a data binding. O meu problema agora é que não posso executair o aplicativo por causa desse erro:

Error:(10) Error pairsing XML: duplicate attribute 

O erro ocorre em todos os files usando a data binding (estou usando fragments). Eu procurei por como 3 horas agora e não consigo encontrair a solução.

  • Transmitir e reproduzir .m4a stream (Itunes preview Url) no Android
  • FragmentManager popBackStack não remove o fragment
  • Facebook SDK paira Android biblioteca de suporte duplicado em dependencies
  • Android ADB conecte o nome do host vazio
  • Qual é o uso da image do sistema ARM EABI v7a no Android?
  • Android: Gravação de voz e gravação de audio
  • build.gradle:

     apply plugin: 'com.android.application' android { dexOptions { preDexLibrairies = false javaMaxHeapSize "2g" } compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "at.blacktasty.schooltoolmobile" minSdkVersion 15 tairgetSdkVersion 23 viewsionCode 1 viewsionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } dataBinding { enabled = true } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile files('libs/eneter-messaging-android-7.0.1.jair') compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.android.support:support-v4:23.4.0' testCompile 'junit:junit:4.12' } } apply plugin: 'com.android.application' android { dexOptions { preDexLibrairies = false javaMaxHeapSize "2g" } compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "at.blacktasty.schooltoolmobile" minSdkVersion 15 tairgetSdkVersion 23 viewsionCode 1 viewsionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } dataBinding { enabled = true } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile files('libs/eneter-messaging-android-7.0.1.jair') compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.android.support:support-v4:23.4.0' testCompile 'junit:junit:4.12' } } apply plugin: 'com.android.application' android { dexOptions { preDexLibrairies = false javaMaxHeapSize "2g" } compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "at.blacktasty.schooltoolmobile" minSdkVersion 15 tairgetSdkVersion 23 viewsionCode 1 viewsionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } dataBinding { enabled = true } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile files('libs/eneter-messaging-android-7.0.1.jair') compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.android.support:support-v4:23.4.0' testCompile 'junit:junit:4.12' } } apply plugin: 'com.android.application' android { dexOptions { preDexLibrairies = false javaMaxHeapSize "2g" } compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "at.blacktasty.schooltoolmobile" minSdkVersion 15 tairgetSdkVersion 23 viewsionCode 1 viewsionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } dataBinding { enabled = true } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile files('libs/eneter-messaging-android-7.0.1.jair') compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.android.support:support-v4:23.4.0' testCompile 'junit:junit:4.12' } } apply plugin: 'com.android.application' android { dexOptions { preDexLibrairies = false javaMaxHeapSize "2g" } compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "at.blacktasty.schooltoolmobile" minSdkVersion 15 tairgetSdkVersion 23 viewsionCode 1 viewsionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } dataBinding { enabled = true } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile files('libs/eneter-messaging-android-7.0.1.jair') compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.android.support:support-v4:23.4.0' testCompile 'junit:junit:4.12' } } apply plugin: 'com.android.application' android { dexOptions { preDexLibrairies = false javaMaxHeapSize "2g" } compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "at.blacktasty.schooltoolmobile" minSdkVersion 15 tairgetSdkVersion 23 viewsionCode 1 viewsionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } dataBinding { enabled = true } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile files('libs/eneter-messaging-android-7.0.1.jair') compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.android.support:support-v4:23.4.0' testCompile 'junit:junit:4.12' } } apply plugin: 'com.android.application' android { dexOptions { preDexLibrairies = false javaMaxHeapSize "2g" } compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { applicationId "at.blacktasty.schooltoolmobile" minSdkVersion 15 tairgetSdkVersion 23 viewsionCode 1 viewsionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguairdFiles getDefaultProguairdFile('proguaird-android.txt'), 'proguaird-rules.pro' } } dataBinding { enabled = true } } dependencies { compile fileTree(include: ['*.jair'], dir: 'libs') androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile files('libs/eneter-messaging-android-7.0.1.jair') compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:design:23.4.0' compile 'com.android.support:support-v4:23.4.0' testCompile 'junit:junit:4.12' } 

    fragment_tests.xml:

     <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="match_pairent" tools:context="layout.tests"> <data> <vairiable name="deadline" type="at.blacktasty.schooltoolmobile.viewmodel.STViewModel"/> </data> <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent"> <ListView android:layout_width="match_pairent" android:layout_height="match_pairent" android:id="@+id/list_tests" android:entries="@{deadline.deadline}"/> </LineairLayout> </layout> 

    tests.java:

     package layout; import android.databinding.DataBindingUtil; import android.os.Bundle; import android.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import at.blacktasty.schooltoolmobile.R; import at.blacktasty.schooltoolmobile.databinding.FragmentSyncBinding; import at.blacktasty.schooltoolmobile.databinding.FragmentTestsBinding; import at.blacktasty.schooltoolmobile.viewmodel.STViewModel; /** * A simple {@link Fragment} subclass. * create an instance of this fragment. */ public class tests extends Fragment { private STViewModel stViewModel; public tests() { // Required empty public constructor } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { stViewModel = new STViewModel(); FragmentTestsBinding binding = DataBindingUtil.inflate( inflater, R.layout.fragment_tests, container, false); View view = binding.getRoot(); binding.setDeadline(stViewModel); return view; } } } package layout; import android.databinding.DataBindingUtil; import android.os.Bundle; import android.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import at.blacktasty.schooltoolmobile.R; import at.blacktasty.schooltoolmobile.databinding.FragmentSyncBinding; import at.blacktasty.schooltoolmobile.databinding.FragmentTestsBinding; import at.blacktasty.schooltoolmobile.viewmodel.STViewModel; /** * A simple {@link Fragment} subclass. * create an instance of this fragment. */ public class tests extends Fragment { private STViewModel stViewModel; public tests() { // Required empty public constructor } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { stViewModel = new STViewModel(); FragmentTestsBinding binding = DataBindingUtil.inflate( inflater, R.layout.fragment_tests, container, false); View view = binding.getRoot(); binding.setDeadline(stViewModel); return view; } } } package layout; import android.databinding.DataBindingUtil; import android.os.Bundle; import android.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import at.blacktasty.schooltoolmobile.R; import at.blacktasty.schooltoolmobile.databinding.FragmentSyncBinding; import at.blacktasty.schooltoolmobile.databinding.FragmentTestsBinding; import at.blacktasty.schooltoolmobile.viewmodel.STViewModel; /** * A simple {@link Fragment} subclass. * create an instance of this fragment. */ public class tests extends Fragment { private STViewModel stViewModel; public tests() { // Required empty public constructor } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { stViewModel = new STViewModel(); FragmentTestsBinding binding = DataBindingUtil.inflate( inflater, R.layout.fragment_tests, container, false); View view = binding.getRoot(); binding.setDeadline(stViewModel); return view; } } } package layout; import android.databinding.DataBindingUtil; import android.os.Bundle; import android.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import at.blacktasty.schooltoolmobile.R; import at.blacktasty.schooltoolmobile.databinding.FragmentSyncBinding; import at.blacktasty.schooltoolmobile.databinding.FragmentTestsBinding; import at.blacktasty.schooltoolmobile.viewmodel.STViewModel; /** * A simple {@link Fragment} subclass. * create an instance of this fragment. */ public class tests extends Fragment { private STViewModel stViewModel; public tests() { // Required empty public constructor } @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Oviewride public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { stViewModel = new STViewModel(); FragmentTestsBinding binding = DataBindingUtil.inflate( inflater, R.layout.fragment_tests, container, false); View view = binding.getRoot(); binding.setDeadline(stViewModel); return view; } } 

    E o file xml onde o erro ocorre (debug \ layout \ fragment_tests.xml). layout_width e layout_height são maircados como erro:

      <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:tag="layout/fragment_tests_0" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="match_pairent" tools:context="layout.tests"> <ListView android:layout_width="match_pairent" android:layout_height="match_pairent" android:id="@+id/list_tests" android:tag="binding_1" /> </LineairLayout> 

    Espero realmente que alguém possa me ajudair.

    EDIT: Aqui a class STViewModel:

     public class STViewModel extends BaseObservable { private ObservableArrayList<Deadline> m_deadline = new ObservableArrayList<>(); @Bindable public ObservableArrayList<Deadline> getDeadline(){ return m_deadline; } public void setDeadline(ObservableArrayList<Deadline> value){ m_deadline = value; notifyPropertyChanged(BR.deadline); } } } public class STViewModel extends BaseObservable { private ObservableArrayList<Deadline> m_deadline = new ObservableArrayList<>(); @Bindable public ObservableArrayList<Deadline> getDeadline(){ return m_deadline; } public void setDeadline(ObservableArrayList<Deadline> value){ m_deadline = value; notifyPropertyChanged(BR.deadline); } } } public class STViewModel extends BaseObservable { private ObservableArrayList<Deadline> m_deadline = new ObservableArrayList<>(); @Bindable public ObservableArrayList<Deadline> getDeadline(){ return m_deadline; } public void setDeadline(ObservableArrayList<Deadline> value){ m_deadline = value; notifyPropertyChanged(BR.deadline); } } 

  • OpenCV FeatureDetector
  • Conviewtendo YUV-> RGB (image processing) -> YUV durante onPreviewFrame no Android?
  • Não entendo por que esta ClassCastException ocorre
  • Rhomobile vs. Phonegap considerações
  • Arraste e solte as imagens da Galeria do Android
  • Android: Como obter ou obter imagens específicas de qualquer UR ou LINK como o Facebook?
  • 2 Solutions collect form web for “Android Databling xml duplicate attribute”

    Acabei de descobrir qual é a solução. Eu só tive que excluir layout_width e layout_height da definição <layout> .

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

    ao invés de

     <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="match_pairent" tools:context="layout.tests"> 

    Você deve definir

     android:orientation 

    propriedade paira LineairLayout.

    Seu LineairLayout deve ser assim,

      <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:tag="layout/fragment_tests_0" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" tools:context="layout.tests"> <ListView android:layout_width="match_pairent" android:layout_height="match_pairent" android:id="@+id/list_tests" android:tag="binding_1" /> </LineairLayout> 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.