Home > Blockchain >  Generated file Error In Android Studio for Unsupported package android.support.v7.widget.RecyclerVie
Generated file Error In Android Studio for Unsupported package android.support.v7.widget.RecyclerVie

Time:03-25

I have Migrated to androidx in previous days. After some days, Once I have created an activity Login_Activity I have found the error in runtime generated file :

D:\AndroidStudioProjects\4_tafheem_new\app\build\generated\data_binding_base_class_source_out\debug\out\com\alquran\tafhimul_quran\databinding\FragmentListBinding.java:4: error: package android.support.v7.widget does not exist
import android.support.v7.widget.RecyclerView;

enter image description here

Here you see that the problems refer to the file : FragmentListBinding.java

But I did not find in project files any uses of import android.support.v7.widget.RecyclerView; I have failed to find where the error comes from. I have deleted the activity Login_Activity, delete build folder, invalidate caches and restart, But no luck. The problem still arises.

CodePudding user response:

At last I have found the error come from a xml layout file named fragment_list :

enter image description here

<android.support.v7.widget.RecyclerView
        android:id="@ id/recycleView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

And I have changed it to :

<androidx.recyclerview.widget.RecyclerView
        android:id="@ id/recycleView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" /> 

And the error has gone.

So, I think, Android studio should point out the actual file in case of generated files errors.

CodePudding user response:

RecyclerViewwas migrated to AndroidX as well:

Updatebuild.gradle:

implementation 'androidx.recyclerview:recyclerview:1.1.0'

Change layout file:

<androidx.recyclerview.widget.RecyclerView
        android:id="@ id/recycleView"
        android:layout_width="match_parent"
        android:layout_height="match_parent" /> 
  • Related