I just migrated my project to androidx and i am getting an inflation error for inflating viewpager component...I replaced android.support.v4.view.ViewPager with androidx.viewpager.widget.ViewPager
This my xml file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:padding="@dimen/_1dp"
android:layout_height="wrap_content"
android:background="@color/banner_border_color">
<androidx.viewpager.widget.ViewPager
android:id="@+id/vp_slider"
android:layout_width="match_parent"
android:layout_height="@dimen/_140dp"
android:background="@drawable/thumb_new_background" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<TextView
android:id="@+id/tv_banner_view_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/_16dp"
android:background="@drawable/drawable_btn_curved"
android:paddingBottom="@dimen/_6dp"
android:paddingLeft="@dimen/_8dp"
android:paddingRight="@dimen/_8dp"
android:paddingTop="@dimen/_6dp"
android:visibility="gone"
android:text="@string/text_view_more"
android:textColor="@color/c_white"
android:textSize="@dimen/_8sp" />
</RelativeLayout>
</FrameLayout>
The Error i'm getting :
Caused by: android.view.InflateException: Binary XML file line #329: Binary XML file line #8: Error inflating class androidx.core.view.ViewPager
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class androidx.core.view.ViewPager
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.view.ViewPager" on path: DexPathList[
I figure out problem, When we merger to androidx then android studio convert viewpager, swipe to refresh layout and some other views to androidx.core for example viewpager its looks like androidx.core.view.ViewPager but correct is androidx.viewpager.widget.ViewPager please check in your xml layouts and see there is right component is added or not if there is androidx.core then check for right one and replace it. And also import dependency
implementation 'com.google.android.material:material:1.1.0-alpha08
You need to below dependencies
in your build.gradle
file
implementation 'com.google.android.material:material:1.1.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With