扩展类android.support.v4.view.ViewPager Android Studio时出错

时间:2017-08-16 13:31:30

标签: java android android-support-library

所以我在我的应用程序中的片段中有一个ViewPager并且它从来没有遇到任何问题但突然(ViewPager部分没有任何变化)它开始崩溃并且logcat看起来像这样< / p>

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) 

这是我的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" />

到目前为止,我已经尝试了所有我能想到但却没有成功的东西......还需要注意我使用的是Android Studio

感谢您的回复

0 个答案:

没有答案