Android应用程序无法在三星设备

时间:2017-01-14 07:15:14

标签: android xml samsung-mobile

当我试图在三星设备上运行我的Android应用时,它始终显示如下错误:

  

app很遗憾被停止了

并且还显示xml充气错误和未找到的可绘制资源,即使我重命名现有的apk并再次安装在android studio中安装的支持库但错误保持不变。 但在redmi 3s设备中它的工作正常。我该怎么办请提出一些建议。 这是我在控制台中的错误:

E/AndroidRuntime: FATAL EXCEPTION: main
              android.content.res.Resources$NotFoundException: Resource ID #0x7f020157
                  at android.content.res.Resources.getValue(Resources.java:1884)
                  at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:330)
                  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:195)
                  at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)
                  at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
                  at android.support.v7.view.menu.MenuItemImpl.getIcon(MenuItemImpl.java:425)
                  at android.support.v7.view.menu.ActionMenuItemView.initialize(ActionMenuItemView.java:132)
                  at android.support.v7.widget.ActionMenuPresenter.bindItemView(ActionMenuPresenter.java:211)
                  at android.support.v7.view.menu.BaseMenuPresenter.getItemView(BaseMenuPresenter.java:186)
                  at android.support.v7.widget.ActionMenuPresenter.getItemView(ActionMenuPresenter.java:197)
                  at android.support.v7.widget.ActionMenuPresenter.flagActionItems(ActionMenuPresenter.java:479)
                  at android.support.v7.view.menu.MenuBuilder.flagActionItems(MenuBuilder.java:1151)
                  at android.support.v7.view.menu.BaseMenuPresenter.updateMenuView(BaseMenuPresenter.java:95)
                  at android.support.v7.widget.ActionMenuPresenter.updateMenuView(ActionMenuPresenter.java:234)
                  at android.support.v7.view.menu.MenuBuilder.dispatchPresenterUpdate(MenuBuilder.java:290)
                  at android.support.v7.view.menu.MenuBuilder.onItemsChanged(MenuBuilder.java:1042)
                  at android.support.v7.view.menu.MenuBuilder.startDispatchingItemsChanged(MenuBuilder.java:1065)
                  at android.support.v7.app.ToolbarActionBar.populateOptionsMenu(ToolbarActionBar.java:460)
                  at android.support.v7.app.ToolbarActionBar$1.run(ToolbarActionBar.java:61)
                  at android.os.Handler.handleCallback(Handler.java:615)
                  at android.os.Handler.dispatchMessage(Handler.java:92)
                  at android.os.Looper.loop(Looper.java:177)
                  at android.app.ActivityThread.main(ActivityThread.java:4947)
                  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:1038)
                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
                  at dalvik.system.NativeStart.main(Native Method)

D / dalvikvm:GC_CONCURRENT释放965K,13%免费14229K / 16199K,暂停21ms + 32ms,总计123ms D / dalvikvm:GC_CONCURRENT释放993K,12%免费14774K / 16775K,暂停12ms + 3ms,总计37ms D / dalvikvm:GC_CONCURRENT释放1591K,15%免费14909K / 17479K,暂停12ms + 14ms,总计145ms 申请已终止。

draweritemmenu.xml这是我的菜单文件。

<menu xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<group android:checkableBehavior="single">
    <item
        android:id="@+id/home"
        android:icon="@drawable/home"
        android:title="Home" />
    <item
        android:id="@+id/signin"
        android:icon="@drawable/login"
        android:title="Sign In" />
    <item android:title="Categories">
        <menu>
            <group android:checkableBehavior="single">
                <item
                    android:id="@+id/fruit"
                    android:icon="@drawable/fruit"
                    android:title="Fruits" />
                <item
                    android:id="@+id/food"
                    android:icon="@drawable/thali"
                    android:title="Food" />
            </group>
        </menu>
    </item>
</group>
<item android:title="Best Deals">
    <menu>
        <group android:checkableBehavior="single">
            <item
                android:id="@+id/fruitoffer"
                android:icon="@drawable/fruitoffer"
                android:title="Offer On Fruits" />
            <item
                android:id="@+id/foodoffer"
                android:icon="@drawable/offer"
                android:title="Offer On Food" />
        </group>
    </menu>
</item>
<item android:title="Communicate">
    <menu>
        <item
            android:id="@+id/aboutus"
         android:icon="@drawable/aboutus"
            android:title="About us" />
        <item
            android:id="@+id/contactus"
            android:icon="@drawable/contactus"
            android:title="Contact us" />
        <item
            android:id="@+id/faq"
            android:icon="@drawable/faq"
            android:title="FAQ" />
    </menu>
</item>

//这是我的动作菜单xml文件

<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="@+id/action_search1"
    android:title="Filter By Food Name" />
<item android:id="@+id/action_search2"
    android:title="Filter By Fruit Name"
    android:icon="@drawable/foodbyname" />
<item android:id="@+id/action_search3"
    android:title="Filter By Food Price" />
<item android:id="@+id/action_search4"
    android:title="Filter By Fruit Price" />

1 个答案:

答案 0 :(得分:1)

似乎找不到一个(或更多)你的drawable(android:icon =&#34; @ drawable / xxx&#34;)。 在我的情况下,我错误地将图片放入drawable-v21(文件夹)(我的设备&#39; API = 19)。当我将它移动到drawable(文件夹)时,它没问题。