StfgMccx StfgMccx - 1 year ago 107
Java Question

Error inflating class android.support.v4.view.ViewPager Android Studio

So i had a ViewPager in a Fragment in my app and it has never had any problems but suddenly (without any change in the viewpager part) it started crashing and the logcat looks like this

08-16 15:05:08.463 28980-28980/com.macura.scholar E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.macura.scholar, PID: 28980
android.view.InflateException: Binary XML file line #44: Binary XML file line #44: Error inflating class android.support.v4.view.ViewPager
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at com.macura.scholar.MainActivity$TimetableFragment.onCreateView(MainActivity.java:744)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1671)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:532)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: android.view.InflateException: Binary XML file line #44: Error inflating class android.support.v4.view.ViewPager
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
at com.macura.scholar.MainActivity$TimetableFragment.onCreateView(MainActivity.java:744) 
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286) 
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758) 
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1671) 
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:532) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:619)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
at com.macura.scholar.MainActivity$TimetableFragment.onCreateView(MainActivity.java:744) 
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286) 
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758) 
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1671) 
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:532) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
Caused by: java.lang.NoSuchMethodError: No static method setOnApplyWindowInsetsListener(Landroid/view/View;Landroid/support/v4/view/OnApplyWindowInsetsListener;)V in class Landroid/support/v4/view/ViewCompatLollipop; or its super classes (declaration of 'android.support.v4.view.ViewCompatLollipop' appears in /data/app/com.macura.scholar-1/split_lib_dependencies_apk.apk:classes50.dex)
at android.support.v4.view.ViewCompat$LollipopViewCompatImpl.setOnApplyWindowInsetsListener(ViewCompat.java:1619)
at android.support.v4.view.ViewCompat.setOnApplyWindowInsetsListener(ViewCompat.java:2924)
at android.support.v4.view.ViewPager.initViewPager(ViewPager.java:427)
at android.support.v4.view.ViewPager.<init>(ViewPager.java:397)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
at com.macura.scholar.MainActivity$TimetableFragment.onCreateView(MainActivity.java:744) 
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2074) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1286) 
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:758) 
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1671) 
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:532) 
at android.os.Handler.handleCallback(Handler.java:739) 
at android.os.Handler.dispatchMessage(Handler.java:95) 
at android.os.Looper.loop(Looper.java:148) 
at android.app.ActivityThread.main(ActivityThread.java:5417) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 


this is my viewpager

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="64dp"
android:layout_gravity="center_horizontal">

<ImageButton
android:id="@+id/timetable_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@drawable/ic_menu_black_24dp"
android:padding="16dp"
android:background="?android:actionBarItemBackground"/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/monday_table"
android:id="@+id/timetable_day"
android:layout_gravity="center_vertical"
android:textColor="@android:color/black"
android:textSize="20sp"
android:layout_marginLeft="8dp"
android:alpha="0.8"
android:layout_weight="1" />

<ImageButton
android:layout_width="48dp"
android:layout_height="48dp"
android:id="@+id/timetable_edit"
android:background="?android:actionBarItemBackground"
android:src="@drawable/ic_create_black_24dp"
android:layout_gravity="center_vertical"
android:layout_weight="0"
android:layout_marginRight="8dp" />
</LinearLayout>

<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />




so far i've tried everything i could think of yet no success... also need to note that im using Android Studio

thanks for any response

Answer Source

Please, post your module build.gradle. Check this link: No static method setOnApplyWindowInsetsListener exception in Android

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download