我正在尝试将操作栏操作按钮添加到我的 Android 应用程序中的操作栏。每次我向 res/menu/(一些 xml 文件)添加一个操作按钮时,我都会收到错误 aapt:Return code 138。所以即使 eclipse 说错误不是因为我的代码,但一定是因为我的代码.每当我将操作按钮添加到我在“菜单”目录中创建的 xml 文件时,就会弹出错误。根据this它与不在 res/values/strings.xml 中声明我的字符串有关。但即使我确实在那里声明了我的字符串,错误仍然会弹出!这简直令人气愤。我将在下面包含我的菜单和字符串 xml 文件,以防它们出现问题。如果您需要更多信息或有其他问题,请随时提出。
strings.xml 文件
<resources>
<string name="app_name">Beacon Portal</string>
<string name="action_settings">Settings</string>
<string name = "edit_item">Action Bar Icon Edit</string>
<string name="hello_world">Hello world!</string>
<string name="Fragment1">This is where the schedule goes when I get around to making that because it seems like some people want that</string>
<string name="FragmentTab1">This is ViewPager Fragment Tab 1</string>
<string name="FragmentTab2">This is ViewPager Fragment Tab 2</string>
<string name="drawer_open">Open navigation drawer</string>
<string name="drawer_close">Close navigation drawer</string>
<!-- Nav Drawer Menu Items -->
<string-array name="nav_drawer_items">
<item >Schedule</item>
<item >Homework Due</item>
<item >Logout</item>
</string-array>
<!-- Nav Drawer List Item Icons -->
<!-- Keep them in order as the titles are in -->
<array name="nav_drawer_icons">
<item>@drawable/ic_action_go_to_today</item>
<item>@drawable/ic_action_duehomework</item>
<item>@drawable/ic_action_logout</item>
</array>
<!-- Content Description -->
<string name="desc_list_item_icon">Item Icon</string>
<!-- general stuff -->
<string name="userid_label">OpenMinds</string>
<!-- titles -->
<string name="title_activity_actionview">ActionView</string>
<string name="title_activity_about">About</string>
<!-- ActionBar -->
<string name="edit">Edit Schedule</string>
<string name="apply">Apply Edits</string>
</resources>
menu_fragment_apply.xml(在 res/menu/中)
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/actionViewApply"
android:icon="@drawable/ic_action_agree"
app:showAsAction="ifRoom"
android:title="@string/apply"/>
</menu>
最佳答案
问题是
app:showAsAction="ifRoom"
应该是
android:showAsAction="ifRoom"
相反。在您使用应用兼容库时使用 app:showAsAction,我假设您在这里没有使用它。
关于android - Eclipse Android : Error executing aapt: Return code 138, 我什么都没做似乎可以修复它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22275836/