android – 选择All导致abc_ic_menu_selectall_material.xml资源NotFoundException

当我在Lollipop前设备上运行我的应用程序并尝试按住任何文本来选择文本时,应用程序将崩溃.

这是我得到的错误:

03-27 10:53:45.794 10156-10156/com.****** E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.******, PID: 10156
android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_menu_selectall_material.xml from drawable resource ID #0x7f02001e
    at android.content.res.Resources.loadDrawable(Resources.java:3448)
    at android.content.res.Resources.getDrawable(Resources.java:1892)
    at com.android.internal.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:388)
    at com.android.internal.view.menu.ActionMenuItemView.initialize(ActionMenuItemView.java:151)
    at com.android.internal.view.menu.ActionMenuPresenter.bindItemView(ActionMenuPresenter.java:263)
    at com.android.internal.view.menu.BaseMenuPresenter.getItemView(BaseMenuPresenter.java:178)
    at com.android.internal.view.menu.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:249)
    at com.android.internal.view.menu.ActionMenuPresenter.flagActionItems(ActionMenuPresenter.java:530)
    at com.android.internal.view.menu.MenuBuilder.flagActionItems(MenuBuilder.java:1062)
    at com.android.internal.view.menu.BaseMenuPresenter.updateMenuView(BaseMenuPresenter.java:87)
    at com.android.internal.view.menu.ActionMenuPresenter.updateMenuView(ActionMenuPresenter.java:302)
    at com.android.internal.view.menu.BaseMenuPresenter.getMenuView(BaseMenuPresenter.java:72)
    at com.android.internal.view.menu.ActionMenuPresenter.getMenuView(ActionMenuPresenter.java:240)
    at com.android.internal.widget.ActionBarContextView.initForMode(ActionBarContextView.java:399)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2552)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2492)
    at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665)
    at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665)
    at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665)
    at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665)
    at android.view.View.startActionMode(View.java:4594)
    at android.widget.Editor.startSelectionActionMode(Editor.java:1656)
    at android.widget.Editor.performLongClick(Editor.java:907)
    at android.widget.TextView.performLongClick(TextView.java:8859)
    at android.view.View$CheckForLongPress.run(View.java:18582)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5426)
    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:1268)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
    at dalvik.system.NativeStart.main(Native Method)
 Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line
    #17: invalid drawable tag vector
    at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:969)
    at android.graphics.drawable.Drawable.createFromXml(Drawable.java:913)
    at android.content.res.Resources.loadDrawable(Resources.java:3444)
    at android.content.res.Resources.getDrawable(Resources.java:1892) 
    at com.android.internal.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:388) 
    at com.android.internal.view.menu.ActionMenuItemView.initialize(ActionMenuItemView.java:151) 
    at com.android.internal.view.menu.ActionMenuPresenter.bindItemView(ActionMenuPresenter.java:263) 
    at com.android.internal.view.menu.BaseMenuPresenter.getItemView(BaseMenuPresenter.java:178) 
    at com.android.internal.view.menu.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:249) 
    at com.android.internal.view.menu.ActionMenuPresenter.flagActionItems(ActionMenuPresenter.java:530) 
    at com.android.internal.view.menu.MenuBuilder.flagActionItems(MenuBuilder.java:1062) 
    at com.android.internal.view.menu.BaseMenuPresenter.updateMenuView(BaseMenuPresenter.java:87) 
    at com.android.internal.view.menu.ActionMenuPresenter.updateMenuView(ActionMenuPresenter.java:302) 
    at com.android.internal.view.menu.BaseMenuPresenter.getMenuView(BaseMenuPresenter.java:72) 
    at com.android.internal.view.menu.ActionMenuPresenter.getMenuView(ActionMenuPresenter.java:240) 
    at com.android.internal.widget.ActionBarContextView.initForMode(ActionBarContextView.java:399) 
    at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2552) 
    at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2492) 
    at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665) 
    at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665) 
    at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665) 
    at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:665) 
    at android.view.View.startActionMode(View.java:4594) 
    at android.widget.Editor.startSelectionActionMode(Editor.java:1656) 
    at android.widget.Editor.performLongClick(Editor.java:907) 
    at android.widget.TextView.performLongClick(TextView.java:8859) 
    at android.view.View$CheckForLongPress.run(View.java:18582) 
    at android.os.Handler.handleCallback(Handler.java:733) 
    at android.os.Handler.dispatchMessage(Handler.java:95) 
    at android.os.Looper.loop(Looper.java:136) 
    at android.app.ActivityThread.main(ActivityThread.java:5426) 
    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:1268) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084) 
    at dalvik.system.NativeStart.main(Native Method)

最佳答案 我找到了一个解决方案,我使用的是compileSdkVersion’android-N’,

显然这是一个在SDK 23.1.0中修复的错误但由于某种原因开发人员未能在android n预览sdk中修复它.回到SDK 23,一切都开始在我的旧设备上再次运行.

点赞