com.example.androiddata.databinding.FragmentDetailBindingImpl.executeBindings(FragmentDetailBindingImpl.java:147)

0

I've already cleaned my project , Rebuild was done...but still no use. Then invalidated caches and restarted the project that too didn't helped me.

I still receive this error from my logcat

2020-06-18 01:36:13.602 16501-16501/com.example.androiddata I/monsterLogging: Selected item: Grade 2
2020-06-18 01:36:13.737 16501-16501/com.example.androiddata I/monsterLogging: Selected Grade level: Grade 2
2020-06-18 01:36:13.746 16501-16501/com.example.androiddata E/ple.androiddat: Invalid ID 0x00000014.
2020-06-18 01:36:13.749 16501-16501/com.example.androiddata D/AndroidRuntime: Shutting down VM


    --------- beginning of crash
2020-06-18 01:36:13.764 16501-16501/com.example.androiddata E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.androiddata, PID: 16501
    java.lang.RuntimeException: Failed to call observer method
        at androidx.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:226)
        at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:194)
        at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:185)
        at androidx.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:36)
        at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:361)
        at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:300)
        at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:339)
        at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:145)
        at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:131)
        at androidx.fragment.app.Fragment.performStart(Fragment.java:2632)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:915)
        at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2097)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1871)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1827)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727)
        at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x14
        at android.content.res.Resources.getText(Resources.java:367)
        at android.widget.TextView.setText(TextView.java:6370)
        at com.example.androiddata.databinding.FragmentDetailBindingImpl.executeBindings(FragmentDetailBindingImpl.java:147)
        at androidx.databinding.ViewDataBinding.executeBindingsInternal(ViewDataBinding.java:473)
        at androidx.databinding.ViewDataBinding.executePendingBindings(ViewDataBinding.java:445)
        at androidx.databinding.ViewDataBinding$OnStartListener.onStart(ViewDataBinding.java:1687)
        at java.lang.reflect.Method.invoke(Native Method)
        at androidx.lifecycle.ClassesInfoCache$MethodReference.invokeCallback(ClassesInfoCache.java:216)
        at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeMethodsForEvent(ClassesInfoCache.java:194) 
        at androidx.lifecycle.ClassesInfoCache$CallbackInfo.invokeCallbacks(ClassesInfoCache.java:185) 
        at androidx.lifecycle.ReflectiveGenericLifecycleObserver.onStateChanged(ReflectiveGenericLifecycleObserver.java:36) 
        at androidx.lifecycle.LifecycleRegistry$ObserverWithState.dispatchEvent(LifecycleRegistry.java:361) 
        at androidx.lifecycle.LifecycleRegistry.forwardPass(LifecycleRegistry.java:300) 
        at androidx.lifecycle.LifecycleRegistry.sync(LifecycleRegistry.java:339) 
        at androidx.lifecycle.LifecycleRegistry.moveToState(LifecycleRegistry.java:145) 
        at androidx.lifecycle.LifecycleRegistry.handleLifecycleEvent(LifecycleRegistry.java:131) 
        at androidx.fragment.app.Fragment.performStart(Fragment.java:2632) 
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManagerImpl.java:915) 
        at androidx.fragment.app.FragmentManagerImpl.addAddedFragments(FragmentManagerImpl.java:2097) 
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManagerImpl.java:1871) 
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManagerImpl.java:1827) 
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManagerImpl.java:1727) 
        at androidx.fragment.app.FragmentManagerImpl$2.run(FragmentManagerImpl.java:150) 
        at android.os.Handler.handleCallback(Handler.java:883) 
        at android.os.Handler.dispatchMessage(Handler.java:100) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:7356) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 


    --------- beginning of system
2020-06-18 01:36:13.807 16501-16501/com.example.androiddata I/Process: Sending signal. PID: 16501 SIG: 9

This is my DetailFragment.kt

import com.example.androiddata.databinding.FragmentDetailBinding
.....
 val binding = FragmentDetailBinding.inflate(
        inflater, container, false
    )
    binding.lifecycleOwner = this
    binding.viewModel = viewModel

    return binding.root
 .....

this is the FragmentDetailBindinglmpl.java

public class FragmentDetailBindingImpl extends FragmentDetailBinding  {

   .......

}

I am getting error in FragmentDetailBinding

this is my frament_detail.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"
        xmlns:tools="http://schemas.android.com/tools">

    <data>

        <variable
                name="viewModel"
                type="com.example.androiddata.ui.shared.SharedViewModel"/>
    </data>

    <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@drawable/grid_item_background"
            android:padding="16dp">



        <EditText
                android:id="@+id/Sequence"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:autofillHints=""
                android:ems="10"
                android:inputType="textPersonName"
                android:text="@{viewModel.selectedMonster.Sequence}"
                tools:ignore="LabelFor,MissingConstraints"
                tools:layout_editor_absoluteX="49dp"
                tools:layout_editor_absoluteY="132dp" />

        <EditText
                android:id="@+id/Description"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:autofillHints=""
                android:ems="10"
                android:inputType="textPersonName"
                android:text="@{viewModel.selectedMonster.Description}"
                tools:ignore="LabelFor,MissingConstraints"
                tools:layout_editor_absoluteX="49dp"
                tools:layout_editor_absoluteY="132dp" />


        <EditText
                android:id="@+id/editTextTextPersonName2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:autofillHints=""
                android:ems="10"
                android:inputType="textPersonName"
                android:text="@{viewModel.selectedMonster.Status}"
                tools:ignore="LabelFor,MissingConstraints"
                tools:layout_editor_absoluteX="49dp"
                tools:layout_editor_absoluteY="132dp" />

    </androidx.constraintlayout.widget.ConstraintLayout>
</layout>

this is my FramentDetailBindinglmpi.java

package com.example.androiddata.databinding;
import com.example.androiddata.R;
import com.example.androiddata.BR;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.view.View;
@SuppressWarnings("unchecked")
public class FragmentDetailBindingImpl extends FragmentDetailBinding  {

    @Nullable
    private static final androidx.databinding.ViewDataBinding.IncludedLayouts sIncludes;
    @Nullable
    private static final android.util.SparseIntArray sViewsWithIds;
    static {
        sIncludes = null;
        sViewsWithIds = null;
    }
    // views
    @NonNull
    private final androidx.constraintlayout.widget.ConstraintLayout mboundView0;
    // variables
    // values
    // listeners
    // Inverse Binding Event Handlers

    public FragmentDetailBindingImpl(@Nullable androidx.databinding.DataBindingComponent bindingComponent, @NonNull View root) {
        this(bindingComponent, root, mapBindings(bindingComponent, root, 4, sIncludes, sViewsWithIds));
    }
    private FragmentDetailBindingImpl(androidx.databinding.DataBindingComponent bindingComponent, View root, Object[] bindings) {
        super(bindingComponent, root, 1
            , (android.widget.EditText) bindings[2]
            , (android.widget.EditText) bindings[1]
            , (android.widget.EditText) bindings[3]
            );
        this.Description.setTag(null);
        this.Sequence.setTag(null);
        this.editTextTextPersonName2.setTag(null);
        this.mboundView0 = (androidx.constraintlayout.widget.ConstraintLayout) bindings[0];
        this.mboundView0.setTag(null);
        setRootTag(root);
        // listeners
        invalidateAll();
    }

    @Override
    public void invalidateAll() {
        synchronized(this) {
                mDirtyFlags = 0x4L;
        }
        requestRebind();
    }

    @Override
    public boolean hasPendingBindings() {
        synchronized(this) {
            if (mDirtyFlags != 0) {
                return true;
            }
        }
        return false;
    }

    @Override
    public boolean setVariable(int variableId, @Nullable Object variable)  {
        boolean variableSet = true;
        if (BR.viewModel == variableId) {
            setViewModel((com.example.androiddata.ui.shared.SharedViewModel) variable);
        }
        else {
            variableSet = false;
        }
            return variableSet;
    }

    public void setViewModel(@Nullable com.example.androiddata.ui.shared.SharedViewModel ViewModel) {
        this.mViewModel = ViewModel;
        synchronized(this) {
            mDirtyFlags |= 0x2L;
        }
        notifyPropertyChanged(BR.viewModel);
        super.requestRebind();
    }

    @Override
    protected boolean onFieldChange(int localFieldId, Object object, int fieldId) {
        switch (localFieldId) {
            case 0 :
                return onChangeViewModelSelectedMonster((androidx.lifecycle.MutableLiveData<com.example.androiddata.data.Monster>) object, fieldId);
        }
        return false;
    }
    private boolean onChangeViewModelSelectedMonster(androidx.lifecycle.MutableLiveData<com.example.androiddata.data.Monster> ViewModelSelectedMonster, int fieldId) {
        if (fieldId == BR._all) {
            synchronized(this) {
                    mDirtyFlags |= 0x1L;
            }
            return true;
        }
        return false;
    }

    @Override
    protected void executeBindings() {
        long dirtyFlags = 0;
        synchronized(this) {
            dirtyFlags = mDirtyFlags;
            mDirtyFlags = 0;
        }
        java.lang.String viewModelSelectedMonsterDescription = null;
        com.example.androiddata.data.Monster viewModelSelectedMonsterGetValue = null;
        androidx.lifecycle.MutableLiveData<com.example.androiddata.data.Monster> viewModelSelectedMonster = null;
        int viewModelSelectedMonsterSequence = 0;
        com.example.androiddata.ui.shared.SharedViewModel viewModel = mViewModel;
        java.lang.String viewModelSelectedMonsterStatus = null;

        if ((dirtyFlags & 0x7L) != 0) {



                if (viewModel != null) {
                    // read viewModel.selectedMonster
                    viewModelSelectedMonster = viewModel.getSelectedMonster();
                }
                updateLiveDataRegistration(0, viewModelSelectedMonster);


                if (viewModelSelectedMonster != null) {
                    // read viewModel.selectedMonster.getValue()
                    viewModelSelectedMonsterGetValue = viewModelSelectedMonster.getValue();
                }


                if (viewModelSelectedMonsterGetValue != null) {
                    // read viewModel.selectedMonster.getValue().Description
                    viewModelSelectedMonsterDescription = viewModelSelectedMonsterGetValue.getDescription();
                    // read viewModel.selectedMonster.getValue().Sequence
                    viewModelSelectedMonsterSequence = viewModelSelectedMonsterGetValue.getSequence();
                    // read viewModel.selectedMonster.getValue().Status
                    viewModelSelectedMonsterStatus = viewModelSelectedMonsterGetValue.getStatus();
                }
        }
        // batch finished
        if ((dirtyFlags & 0x7L) != 0) {
            // api target 1

            androidx.databinding.adapters.TextViewBindingAdapter.setText(this.Description, viewModelSelectedMonsterDescription);
            this.Sequence.setText(viewModelSelectedMonsterSequence);
            androidx.databinding.adapters.TextViewBindingAdapter.setText(this.editTextTextPersonName2, viewModelSelectedMonsterStatus);
        }
    }
    // Listener Stub Implementations
    // callback impls
    // dirty flag
    private  long mDirtyFlags = 0xffffffffffffffffL;
    /* flag mapping
        flag 0 (0x1L): viewModel.selectedMonster
        flag 1 (0x2L): viewModel
        flag 2 (0x3L): null
    flag mapping end*/
    //end
}

this is my SharedViewModel

class SharedViewModel(val app: Application) : AndroidViewModel(app) {
    private val dataRepo = MonsterRepository(app)
    val monsterData = dataRepo.monsterData

    val selectedMonster = MutableLiveData<Monster>()
    val activityTitle = MutableLiveData<String>()

    init {
        updateActivityTitle()
    }

    fun refreshData() {
        dataRepo.refreshDataFromWeb()
    }

    fun updateActivityTitle() {
        val signature =
            PreferenceManager.getDefaultSharedPreferences(app)
                .getString("", "")
        activityTitle.value = "Grade Level $signature"
    }

}
android
kotlin
asked on Stack Overflow Jun 17, 2020 by (unknown user) • edited Jun 17, 2020 by (unknown user)

1 Answer

0

Is viewModel.selectedMonster.Sequence of type int? android:text with an int assumes that the int is a string resource ID.

Use android:text="@{Integer.toString(viewModel.selectedMonster.Sequence)}" in your EditText.

answered on Stack Overflow Jun 17, 2020 by AlphaOne • edited Jun 18, 2020 by AlphaOne

User contributions licensed under CC BY-SA 3.0