Why am I getting the exception: Unable to collect necessary methods for class java.lang.NoSuchMethodException at onCreateViewHolder

I have three fragments Dashboard, Income, Expense. When I open the app and move from Dashboard to either Income or Expense fragment for the first time I am getting the exception. But when I am togging then, it is not happening.

I am using FirebaseRecyclerAdapter I am getting the exception trace

2020-08-28 21:07:34.342 11300-11300/com.example.xpensemanager E/TypefaceCompatApi26Impl: Unable to collect necessary methods for class java.lang.NoSuchMethodException
    java.lang.NoSuchMethodException: android.graphics.FontFamily.<init> []
        at java.lang.Class.getConstructor0(Class.java:2332)
        at java.lang.Class.getConstructor(Class.java:1728)
        at androidx.core.graphics.TypefaceCompatApi26Impl.obtainFontFamilyCtor(TypefaceCompatApi26Impl.java:321)
        at androidx.core.graphics.TypefaceCompatApi26Impl.<init>(TypefaceCompatApi26Impl.java:84)
        at androidx.core.graphics.TypefaceCompatApi28Impl.<init>(TypefaceCompatApi28Impl.java:36)
        at androidx.core.graphics.TypefaceCompat.<clinit>(TypefaceCompat.java:47)
        at androidx.core.graphics.TypefaceCompat.create(TypefaceCompat.java:190)
        at androidx.appcompat.widget.AppCompatTextView.setTypeface(AppCompatTextView.java:705)
        at android.widget.TextView.resolveStyleAndSetTypeface(TextView.java:2183)
        at android.widget.TextView.setTypefaceFromAttrs(TextView.java:2154)
        at android.widget.TextView.applyTextAppearance(TextView.java:4105)
        at android.widget.TextView.<init>(TextView.java:1630)
        at android.widget.TextView.<init>(TextView.java:990)
        at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:99)
        at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:95)
        at androidx.appcompat.app.AppCompatViewInflater.createTextView(AppCompatViewInflater.java:182)
        at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:103)
        at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1407)
        at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1457)
        at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1059)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:995)
        at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:959)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1121)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1124)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
        at android.view.LayoutInflater.rInflate(LayoutInflater.java:1124)
        at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1082)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:680)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
        at com.example.xpensemanager.IncomeFragment$2.onCreateViewHolder(IncomeFragment.java:126)
        at com.example.xpensemanager.IncomeFragment$2.onCreateViewHolder(IncomeFragment.java:112)
        at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7078)

in the code

 public void onStart() {
        super.onStart();

        FirebaseRecyclerOptions<Data> options =
                new FirebaseRecyclerOptions.Builder<Data>()
                        .setQuery(mIncomeDatabase, Data.class)
                        .build();

        FirebaseRecyclerAdapter<Data, MyViewHolder> adapter = new FirebaseRecyclerAdapter<Data, MyViewHolder>(options) {
            @Override
            protected void onBindViewHolder(@NonNull MyViewHolder myViewHolder, int i, @NonNull Data data) {

                myViewHolder.setAmount(data.getAmount(), R.id.amount_txt_income);
                myViewHolder.setDate(data.getDate(), R.id.date_txt_income);
                myViewHolder.setNote(data.getNote(), R.id.note_txt_income);
                myViewHolder.setType(data.getType(), R.id.type_txt_income);

            }

            @NonNull
            @Override
            public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
                View myView = LayoutInflater.from(parent.getContext()).inflate(R.layout.income_recycler_data, parent, false);
                MyViewHolder holder = new MyViewHolder(myView);
                return holder;
            }
        };

        recyclerView.setAdapter(adapter);

        adapter.startListening();

    }

at the line

View myView = LayoutInflater.from(parent.getContext()).inflate(R.layout.income_recycler_data, parent, false);

But the app is working fine.

Go to Source
Author: Mohammed Abdul Nafay