我的应用程序在android 5+上正常工作但在低于5的版本上,它给了我这个错误:
InflateException:二进制XML文件行#37:错误输出类android.support.v4.view.ViewPager
我搜索了很多,但这并没有帮助我。编译SDK和目标SDK是24。
这是我的logcat:
08-20 09:06:30.125 27168-27168/com.example.sher.jasonrecyclerdemo W/dalvikvm: VFY: unable to resolve interface method 19816: Landroid/view/Window$Callback;.onProvideKeyboardShortcuts (Ljava/util/List;Landroid/view/Menu;I)V
08-20 09:06:30.125 27168-27168/com.example.sher.jasonrecyclerdemo W/dalvikvm: VFY: unable to find class referenced in signature (Landroid/view/SearchEvent;)
08-20 09:06:30.125 27168-27168/com.example.sher.jasonrecyclerdemo W/dalvikvm: VFY: unable to resolve interface method 19818: Landroid/view/Window$Callback;.onSearchRequested (Landroid/view/SearchEvent;)Z
08-20 09:06:30.125 27168-27168/com.example.sher.jasonrecyclerdemo W/dalvikvm: VFY: unable to resolve interface method 19822: Landroid/view/Window$Callback;.onWindowStartingActionMode (Landroid/view/ActionMode$Callback;I)Landroid/view/ActionMode;
08-20 09:06:30.125 27168-27168/com.example.sher.jasonrecyclerdemo W/dalvikvm: VFY: unable to resolve virtual method 492: Landroid/content/res/TypedArray;.getChangingConfigurations ()I
08-20 09:06:30.125 27168-27168/com.example.sher.jasonrecyclerdemo W/dalvikvm: VFY: unable to resolve virtual method 514: Landroid/content/res/TypedArray;.getType (I)I
08-20 09:06:30.185 27168-27168/com.example.sher.jasonrecyclerdemo I/AppCompatViewInflater: app:theme is now deprecated. Please move to using android:theme instead.
08-20 09:06:30.215 27168-27168/com.example.sher.jasonrecyclerdemo W/ResourceType: Failure getting entry for 0x7f02004d (t=1 e=77) in package 0 (error -75) name=com.example.sher.jasonrecyclerdemo
08-20 09:06:30.215 27168-27168/com.example.sher.jasonrecyclerdemo W/dalvikvm: threadid=1: thread exiting with uncaught exception (group=0x416bde18)
08-20 09:06:30.225 27168-27168/com.example.sher.jasonrecyclerdemo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.sher.jasonrecyclerdemo, PID: 27168
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sher.jasonrecyclerdemo/com.example.sher.jasonrecyclerdemo.MainActivity}: android.view.InflateException: Binary XML file line #37: Error inflating class android.support.v4.view.ViewPager
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5872)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #37: Error inflating class android.support.v4.view.ViewPager
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)
at com.example.sher.jasonrecyclerdemo.MainActivity.onCreate(MainActivity.java:87)
at android.app.Activity.performCreate(Activity.java:5312)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2552)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5872)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)
at com.example.sher.jasonrecyclerdemo.MainActivity.onCreate(MainActivity.java:87)
at android.app.Activity.performCreate(Activity.java:5312)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2552)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5872)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f02004d a=-1 r=0x7f02004d}
at android.content.res.Resources.loadDrawable(Resources.java:2106)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.view.View.<init>(View.java:3596)
at android.view.View.<init>(View.java:3526)
at android.view.ViewGroup.<init>(ViewGroup.java:464)
at android.support.v4.view.ViewPager.<init>(ViewPager.java:396)
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)
at com.example.sher.jasonrecyclerdemo.MainActivity.onCreate(MainActivity.java:87)
at android.app.Activity.performCreate(Activity.java:5312)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2552)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2653)
at android.app.ActivityThread.access$800(ActivityThread.java:156)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5872)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
at dalvik.system.NativeStart.main(Native Method)
答案 0 :(得分:0)
根据您离开此处的Logcat堆栈跟踪,我猜您的代码中存在多个问题或兼容性错误,因此您的活动中不仅有一个错误。
首先,您应该将您为 adaper 课程提供的 Context
结帐到充气。
看起来您已将 input
作为 Drawable
传递,但它似乎是 int
价值或其他。
您也可以查找由&#39;引起的&#39; logcat堆栈中的单词跟踪,因为确切的错误消息总是在此之后出现。