error: cannot find symbol class ActivityMainBindingImpl - android

I am learning about Data binding, I tried 3 times now, and I did exactly as the tutorial but I keep getting the error "error: cannot find symbol class ActivityMainBindingImpl" when I run the app,
It generates a java file with the ActivityMainBindingImpl, should be any problem in my SDK?
Main :
private ActivityMainBinding activityMainBinding;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
activityMainBinding = DataBindingUtil.setContentView(this,R.layout.activity_main);
activityMainBinding.setPerson(getCurrentPerson());
}
public Person getCurrentPerson(){
Person person = new Person();
person.setName("lance");
person.setLastName("claudio");
return person;
}
Model :
public class Person {
private String name;
public Person(String name, String lastName) {
this.name = name;
this.lastName = lastName;
}
public Person() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
private String lastName;
}
XML:
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
<variable
name="person"
type="com.pedrovs.databindingexample.Person" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#{person.setName()}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#{person.setLastName()}">
</TextView>
</LinearLayout>
</layout>
This is my Gradle:APP
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
dataBinding{
enabled=true
}
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.pedrovs.databindingexample"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
Databinding is also enabled in Gradle.
Thank you!

use this xml:
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
<variable
name="person"
type="com.pedrovs.databindingexample.Person" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#{person.name}"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#{person.lastName}">
</TextView>
</LinearLayout>
</layout>
you had error in using databinding in xml chek my code with your's everywhere that you used person in your xml.

Related

databinding msg Could not find accessor within kotlin dataclass

Error message
Found data binding error(s):
[databinding] {"msg":"Could not find accessor com.dubhe.room.entity.User.name","file":"app\\src\\main\\res\\layout\\activity_add_user.xml","pos":[{"line0":31,"col0":28,"line1":31,"col1":36}]}
My layout XML
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<import
alias="user"
type="com.dubhe.room.entity.User" />
<variable
name="add"
type="android.view.View.OnClickListener" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:title="addUser" />
<EditText
android:id="#+id/editUserName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="name"
android:text="#{user.name}" /> <-error in this line.
<EditText
android:id="#+id/editUserAge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="age"
android:inputType="number"
android:text="#{user.age}" />
<Button
android:id="#+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="#{add}"
android:text="Add" />
</LinearLayout>
</layout>
My entity is a kotlin data class.
#Entity(tableName = "user")
data class User(
#PrimaryKey(autoGenerate = true) #ColumnInfo(name = "user_id") var id: Int = 0,
#ColumnInfo(name = "user_name")var name: String = "",
#ColumnInfo(name = "user_age")var age: Int = 0,
#Ignore var isChecked: Boolean = false
)
build.gradle in app directory.
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.dubhe.databinding"
minSdkVersion 23
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
dataBinding {
enabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.1.0-alpha08'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
// implementation 'com.android.support:support-vector-drawable:29.0.0'
implementation 'androidx.core:core-ktx:1.0.2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//Room
implementation 'android.arch.persistence.room:runtime:2.1.4'
//BaseRecyclerViewAdapter
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:2.9.46'
annotationProcessor 'android.arch.persistence.room:compiler:2.1.4'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
}
No matter if I clean and rebuild or Invalidate Caches, I can't compile.
You are using an import instead of a variable:
This:
<import alias="user" type="com.dubhe.room.entity.User" />
should be this:
<variable name="user" type="com.dubhe.room.entity.User" />

error when data binding in android causes cannnot find symbol ActivityMainBindingImpl

So, I'm trying to create an onclick listener on a button using databinding using this tutorial.
databinding tutorial so as far as when I keep the onclick inside my activity_main.xml layout the button click works. But I want to send my data to an include_main_layout.xml but it tells me I have the error..
build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
dataBinding {
enabled = true
}
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.datahelpsworld"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
MainActivity.java
public class MainActivity extends AppCompatActivity {
User user;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
user = new User();
user.setEmail("Ebola chebola chernobyl caronvirus");
user.setName("dilo dilo bolo bolo");
binding.setUser(user);
MyClickHandlers handlers = new MyClickHandlers(this);
binding.setHandlers(handlers);
}
public class MyClickHandlers {
Context context;
public MyClickHandlers(Context context) {
this.context = context;
}
public void onFabClicked(View view) {
user.setName("Ashutosh is awesome");
user.setEmail("email address is magical and cannot be retrieved");
Toast.makeText(getApplicationContext(), "FAB clicked!", Toast.LENGTH_SHORT).show();
}
public void onButtonClick() {
Toast.makeText(getApplicationContext(), "Button clicked!", Toast.LENGTH_SHORT).show();
}
public void onButtonClickWithParam(View view, User user) {
Toast.makeText(getApplicationContext(), "Button clicked! Name: " + user.getName(), Toast.LENGTH_SHORT).show();
}
public boolean onButtonLongPressed(View view) {
Toast.makeText(getApplicationContext(), "Button long pressed!", Toast.LENGTH_SHORT).show();
return false;
}
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:bind="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="handlers"
type="com.example.datahelpsworld.MainActivity.MyClickHandlers" />
<variable
name="user"
type="com.example.datahelpsworld.User" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context=".MainActivity">
<include
layout="#layout/main_layout"
bind:handlers="#{handlers}"
bind:user="#{user}" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:longClickable="true"
android:onClick="#{(v)->handlers.onFabClicked()}"
android:text="activity main layout">
</Button>
</LinearLayout>
</layout>
main_layout.xml
<layout>
<data>
<variable
name="user"
type="com.example.datahelpsworld.User" />
<variable
name="handlers"
type="com.example.datahelpsworld.MainActivity.MyClickHandlers" />
</data>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#{user.name}">
</TextView>
<TextView
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#{user.email}">
</TextView>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="#={(v)->handlers.onButtonClick()}"
android:text="inside include">
</Button>
</LinearLayout>
</layout>
my error is the following lines..
error: cannot find symbol class ActivityMainBindingImpl
I tried cleaning the project and rebuilding from the ground base but still no luck. What is it that I'm doing wrong?
Problem is here.
android:onClick="#{(v)->handlers.onFabClicked()}"
it should be android:onClick="#{handlers.onFabClicked()}" simple.
If you want to pass view parameter from xml then your onClick methos should be like below.
android:onClick="#{(v)->handlers.onFabClicked(v)}"

Error:(7, 36) error: package example.com.test.databinding does not exist

This is the First time i am using Data Binding ,and from Couple of Hours i am having above error. There is Sufficient question related to same Question but Not able to Solve this issue.
Gradle Module APP
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "example.com.test"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
Main_xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="user"
type="example.com.test.MainActivity" />
<import type="android.view.View" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/firstName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#{user.firstName}" />
<TextView
android:id="#+id/lastName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#{user.lastName}" />
</LinearLayout>
</layout>
Modal Class
public class User {
public final String firstName;
public final String lastName;
public User(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public String getFirstName() {
return this.firstName;
}
public String getLastName() {
return this.lastName;
}
}
Main Activity
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String sMan = "Test";
ActivityMainBinding activityMainBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
User mainActivityPresenter = new User(sMan,sMan);
activityMainBinding.setUser(mainActivityPresenter);
}
}
Image is added of log
I am not able to solve this issue.How can this issue be solved??
There are lots of things incorrect in your implementation.
Your model class should extend BaseObservable.
Your getters should be #Bindable
Your setters should call notifyPropertyChanged(..)
In your xml, you are saying that "user" is a example.com.test.MainActivity, while I think it is a User?
User mainActivityPresenter = new User(sMan,sMan); is also very weird. Call a User "user" and a Presenter "xxxPresenter". Don't call a User "presenter" if you want to write clear code.
... these are some things I see at a glance, there's probably more. Please read the documentation completely first, it will make your implementation a lot easier:
https://developer.android.com/topic/libraries/data-binding/index.html
Its the Simple and Silly Error i have Done this Time.
Solved with Changing the MainActivity to User
<data>
<variable
name="user"
type="example.com.test.User" />
<import type="android.view.View" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/firstName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#{user.firstName}" />
<TextView
android:id="#+id/lastName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#{user.lastName}" />
</LinearLayout>

android package *.databinding does not exist

I read more links about this problem, but i dont know whats exactly problem of my project. i set dataBinding as true on build.gradle, below code is my application build.gradle file content
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.text.myapp"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
repositories {
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://clojars.org/repo/" }
}
def support_library = "25.2.0"
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:appcompat-v7:${support_library}"
compile "com.android.support:support-v13:${support_library}"
compile "com.android.support:cardview-v7:${support_library}"
compile "com.android.support:recyclerview-v7:${support_library}"
}
My activity:
public class ActivityRegister extends AppCompatActivity {
private ActivityRegisterBinding binding;
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_register);
}
}
and then, activity layout
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="presenter"
type="ir.pishguy.cafealachiqpro.Ui.Register.ActivityMain.Model.ActivityRegisterViewModel"/>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="-5dp"
android:orientation="vertical">
<TextView
android:id="#+id/default_port"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="#dimen/default_textview_height"/>
</LinearLayout>
</layout>
Error on Logcat:
/Users/mahdi/Desktop/Home/Projects/Android/CafeAlachiqPro/app/src/main/java/com/text/myapp/Ui/Register/ActivityMain/Presenter/ActivityRegister.java
Error:(11, 45) error: package com.text.myapp.databinding does not exist
Error:(19, 13) error: cannot find symbol class ActivityRegisterBinding
Warning:The following options were not recognized by any processor:
'[android.databinding.artifactType, android.databinding.printEncodedErrors, android.databinding.minApi, android.databinding.isTestVariant, android.databinding.enableDebugLogs, android.databinding.sdkDir, android.databinding.bindingBuildFolder, android.databinding.enableForTests, android.databinding.modulePackage, android.databinding.generationalFileOutDir, android.databinding.xmlOutDir]'
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
My viewModel:
public class ActivityRegisterViewModel extends BaseObservable {
private String readContactPermission;
private String getMessages;
public ActivityRegisterViewModel() {
}
#Bindable
public String getReadContactPermission() {
return readContactPermission;
}
public void setReadContactPermission(String readContactPermission) {
this.readContactPermission = readContactPermission;
notifyChange();
}
public String getGetMessages() {
return getMessages;
}
public void setGetMessages(String getMessages) {
this.getMessages = getMessages;
}
}
Remove
apply plugin: 'com.neenbedankt.android-apt'
and
apt "com.github.Raizlabs.DBFlow:dbflow-processor:${dbflow_version}"
from gradle. This helps me to get rid of this error.
Although I could run your project cause ir.pishguy.cafealachiqpro.Ui.Register.Robot.Model.RobotViewModel can not be resolved from robot_user_action.xml
<data class="UserMessagesDataBinding">
<variable
name="viewModel"
type="ir.pishguy.cafealachiqpro.Ui.Register.Robot.Model.RobotViewModel">
</variable>
</data>
Please mention the variable tag which defines your viewmodel as follows :
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="<variablename>"
type="<packagename.YourViewModel>" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="-5dp"
android:orientation="vertical">
<TextView
android:id="#+id/default_port"
android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="#dimen/default_textview_height"/>
</LinearLayout>
</layout>

Android Databinding xml duplicate attribute

I recently started developing on an android application which uses databinding. My problem now is that I can't run the app because of this error:
Error:(10) Error parsing XML: duplicate attribute
The error occurs in every file using databinding (I am using fragments). I googled for like 3 hours now and I can't find the solution.
build.gradle:
apply plugin: 'com.android.application'
android {
dexOptions {
preDexLibraries = false
javaMaxHeapSize "2g"
}
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "at.blacktasty.schooltoolmobile"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
compile fileTree(include: ['*.jar'], 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.jar')
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_parent"
android:layout_height="match_parent"
tools:context="layout.tests">
<data>
<variable
name="deadline"
type="at.blacktasty.schooltoolmobile.viewmodel.STViewModel"/>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/list_tests"
android:entries="#{deadline.deadline}"/>
</LinearLayout>
</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
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
#Override
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;
}
}
And the xml file where the error occurs (debug\layout\fragment_tests.xml). layout_width and layout_height are marked as error:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" 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_parent" android:layout_height="match_parent" tools:context="layout.tests">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/list_tests"
android:tag="binding_1" />
</LinearLayout>
I really hope someone can help me out.
EDIT: Here the STViewModel class:
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);
}
}
I've just found out what the solution is. I just had to delete layout_width and layout_height from the <layout> definition.
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="layout.tests">
instead of
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="layout.tests">
Make sure that xmlns:android isn't automatically added to both <layout> and your actual layout ViewGroup:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
...>
</android.support.v4.widget.DrawerLayout>
</layout>
Remove xmlns:android from either place.
Remove the lines
android:layout_width="match_parent"
android:layout_height="match_parent"
under your layout tag in xml. It will result in build error.
i was using "xmlns" attrinute two time that is why was receiving error.
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/offwhite">
Fixed with below code
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/offwhite">
Its got solved by removing all attributes from <layout> fields, i.e by keeping it like
<layout>
<data>
<variable
name=""
type="" />
</data>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
</LinearLayout>
</layout>
You should define
android:orientation
property to LinearLayout.
Your LinearLayout should be like this,
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
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_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="layout.tests">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/list_tests"
android:tag="binding_1" />
</LinearLayout>

Categories

Resources