不幸的是Android应用停止了由android:drawableBottom

时间:2017-11-07 19:17:05

标签: android

我的布局XML中有 android.support.v7.widget.AppCompatButton 。我的应用程序在Android SDK 21上正常运行,但不幸的是,它在Android SDK 16中停止了(我在AndroidManifest.xml中的minSDKVersion是16)。 我的 AppCompatButton 是这样的:

<android.support.v7.widget.AppCompatButton
        android:id="@+id/button_next"
        android:layout_width="45dp"
        android:layout_height="25dp"
        android:layout_gravity="center_vertical|start"
        android:drawableBottom="@drawable/ic_navigate_next" />

并且错误是这样的:

11-07 22:20:36.774 3300-3300/? E/AndroidRuntime: FATAL EXCEPTION: main
                                             java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp.app/com.myapp.app.Activity}: android.view.InflateException: Binary XML file line #97: Error inflating class <unknown>
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2071)
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
                                                 at android.app.ActivityThread.access$600(ActivityThread.java:138)
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
                                                 at android.os.Handler.dispatchMessage(Handler.java:99)
                                                 at android.os.Looper.loop(Looper.java:213)
                                                 at android.app.ActivityThread.main(ActivityThread.java:4787)
                                                 at java.lang.reflect.Method.invokeNative(Native Method)
                                                 at java.lang.reflect.Method.invoke(Method.java:511)
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
                                                 at dalvik.system.NativeStart.main(Native Method)
                                              Caused by: android.view.InflateException: Binary XML file line #97: Error inflating class <unknown>
                                                 at android.view.LayoutInflater.createView(LayoutInflater.java:613)
                                                 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
                                                 at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830)
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
                                                 at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292)
                                                 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
                                                 at com.virascience.app.SearchActivity.onCreate(SearchActivity.java:90)
                                                 at android.app.Activity.performCreate(Activity.java:5008)
                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096) 
                                                 at android.app.ActivityThread.access$600(ActivityThread.java:138) 
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207) 
                                                 at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                 at android.os.Looper.loop(Looper.java:213) 
                                                 at android.app.ActivityThread.main(ActivityThread.java:4787) 
                                                 at java.lang.reflect.Method.invokeNative(Native Method) 
                                                 at java.lang.reflect.Method.invoke(Method.java:511) 
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556) 
                                                 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:417)
                                                 at android.view.LayoutInflater.createView(LayoutInflater.java:587)
                                                 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
                                                 at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830) 
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:736) 
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
                                                 at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292) 
                                                 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                 at com.virascience.app.SearchActivity.onCreate(SearchActivity.java:90) 
                                                 at android.app.Activity.performCreate(Activity.java:5008) 
                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035) 
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096) 
                                                 at android.app.ActivityThread.access$600(ActivityThread.java:138) 
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207) 
                                                 at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                 at android.os.Looper.loop(Looper.java:213) 
                                                 at android.app.ActivityThread.main(ActivityThread.java:4787) 
                                                 at java.lang.reflect.Method.invokeNative(Native Method) 
                                                 at java.lang.reflect.Method.invoke(Method.java:511) 
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556) 
                                                 at dalvik.system.NativeStart.main(Native Method) 
                                              Caused by: android.content.res.Resources$NotFoundException: File res/drawable/ic_navigate_next.xml from drawable resource ID #0x7f02007d
                                                 at android.content.res.Resources.loadDrawable(Resources.java:1923)
                                                 at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
                                                 at android.widget.TextView.<init>(TextView.java:634)
                                                 at android.widget.Button.<init>(Button.java:107)
                                                 at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:66)
                                                 at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:62)
                                                 at java.lang.reflect.Constructor.constructNative(Native Method) 
                                                 at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
                                                 at android.view.LayoutInflater.createView(LayoutInflater.java:587) 
                                                 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
                                                 at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830) 
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:736) 
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
                                                 at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292) 
                                                 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                 at com.virascience.app.SearchActivity.onCreate(SearchActivity.java:90) 
                                                 at android.app.Activity.performCreate(Activity.java:5008) 
                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035) 
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096) 
                                                 at android.app.ActivityThread.access$600(ActivityThread.java:138) 
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207) 
                                                 at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                 at android.os.Looper.loop(Looper.java:213) 
                                                 at android.app.ActivityThread.main(ActivityThread.java:4787) 
                                                 at java.lang.reflect.Method.invokeNative(Native Method) 
                                                 at java.lang.reflect.Method.invoke(Method.java:511) 
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556) 
                                                 at dalvik.system.NativeStart.main(Native Method) 
                                              Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #1: invalid drawable tag vector
                                                 at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:886)
                                                 at android.graphics.drawable.Drawable.createFromXml(Drawable.java:822)
                                                 at android.content.res.Resources.loadDrawable(Resources.java:1920)
                                                 at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 
                                                 at android.widget.TextView.<init>(TextView.java:634) 
                                                 at android.widget.Button.<init>(Button.java:107) 
                                                 at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:66) 
                                                 at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:62) 
                                                 at java.lang.reflect.Constructor.constructNative(Native Method) 
                                                 at java.lang.reflect.Constructor.newInstance(Constructor.java:417) 
                                                 at android.view.LayoutInflater.createView(LayoutInflater.java:587) 
                                                 at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687) 
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
                                                 at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830) 
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:736) 
                                                 at android.view.LayoutInflater.rInflate(LayoutInflater.java:749) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
                                                 at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
                                                 at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:292) 
                                                 at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
                                                 at com.virascience.app.SearchActivity.onCreate(SearchActivity.java:90) 
                                                 at android.app.Activity.performCreate(Activity.java:5008) 
                                                 at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079) 
                                                 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035) 
                                                 at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096) 
                                                 at android.app.ActivityThread.access$600(ActivityThread.java:138) 
                                                 at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207) 
                                                 at android.os.Handler.dispatchMessage(Handler.java:99) 
                                                 at android.os.Looper.loop(Looper.java:213) 
                                                 at android.app.ActivityThread.main(ActivityThread.java:4787) 
                                                 at java.lang.reflect.Method.invokeNative(Native Method) 
                                                 at java.lang.reflect.Method.invoke(Method.java:511) 
                                                 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789) 
                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556) 
                                                 at dalvik.system.NativeStart.main(Native Method) 

为什么会出现此问题以及如何解决此问题?

2 个答案:

答案 0 :(得分:0)

您可能已根据版本/ screen_size将可绘制文件夹分开 确保您的drawable存在于所有版本中,或者如果您没有,只需将它的副本放在您的基础“drawable”文件夹中

android:drawableBottom="@drawable/ic_navigate_next"

ic_navigate_next 必须位于所有可绘制文件夹中或主要可绘制

中的一个普通文件夹中

看看它有用吗?

答案 1 :(得分:0)

如果你的drawable是一个可绘制的矢量,那么可能就是它。 看到: 这是[链接](Is it possible to use VectorDrawable in Buttons and TextViews using android:DrawableRight?)!