Android Eclipse 执行 aapt 时出错:返回代码 139
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13865748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android Eclipse Error executing aapt: return code 139
提问by Patrick
I have an Android application project that suddenly stopped to work. There is apparently no error, but when I try to launch, I get this:
我有一个突然停止工作的 Android 应用程序项目。显然没有错误,但是当我尝试启动时,我得到了这个:
Error executing aapt: return code 139
执行 aapt 时出错:返回代码 139
I tried to clean the project and its dependent library project, restarted Eclipse, updated to latest ADT and SDK versions, etc. but all failed. I also have this other error sometimes (without changing anything):
我试图清理项目及其依赖库项目,重新启动 Eclipse,更新到最新的 ADT 和 SDK 版本等,但都失败了。我有时也有这个其他错误(没有改变任何东西):
Error generating final archive: java.io.FileNotFoundException: .../bin/resources.ap_ does not exist
生成最终存档时出错:java.io.FileNotFoundException: .../bin/resources.ap_ 不存在
I'm completely lost.
我完全迷失了。
MORE INFO
更多信息
I spent hours to disassemble and reassemble everything piece by piece, and finally found what causes these errors, though I still don't understand anything better... I had a resource like this:
我花了几个小时把所有的东西一块一块地拆开重新组装,终于找到了导致这些错误的原因,虽然我仍然不明白什么......我有一个这样的资源:
<resources>
<integer-array name="titi">
<item>@+id/toto</item>
</integer-array>
</resources>
I removed it and everything worked again... Of course the resource file had no error at all. Half a day lost for nothing, this Eclipse is driving me mad 8-/ Am I the only one?
我删除了它,一切又重新开始了……当然,资源文件根本没有错误。白白浪费了半天,这Eclipse快把我逼疯了8-/只有我一个人吗?
回答by Nima G
Just had the same issue and the problem was that I had a menu file inside the menu folder which had an android:title="@string/.."
that did not exist in my strings file. After adding it and doing a Project > Clean
the problem is gone.
刚刚遇到了同样的问题,问题是我的菜单文件夹中有一个菜单文件,而android:title="@string/.."
我的字符串文件中不存在该文件。添加它并执行之后Project > Clean
,问题就消失了。
回答by Sensei
Don't use @+id/...
here:
不要@+id/...
在这里使用:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<integer-array name="titi">
<Item>@+id/Toto</item>
</integer-array>
</resources>
@+id/...
can only be used in layout resources.
@+id/...
只能在布局资源中使用。
Use @id/...
and generate ids with help resource file if needed:
res/values/ids.xml:
@id/...
如果需要,使用和生成带有帮助资源文件的 id:
res/values/ids.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item type="id" name="toto" />
</resources>
http://developer.android.com/guide/topics/resources/more-resources.html#Id
http://developer.android.com/guide/topics/resources/more-resources.html#Id
回答by Charles Madere
I just moved a project away from using the Android v7 appcompat support libraryand encountered this problem. Turns out that I had a bunch of menu resource files that were still using the appcompat version of some of their properties.
我刚刚将一个项目从使用Android v7 appcompat 支持库移开并遇到了这个问题。结果发现我有一堆菜单资源文件,它们仍在使用其某些属性的 appcompat 版本。
I used to have this:
我曾经有这个:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:compat="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/conversations_activity_menu_contacts"
android:title="@string/contacts"
compat:showAsAction="ifRoom|withText" />
</menu>
But then corrected the problem by changing them to this:
但随后通过将它们更改为以下来纠正问题:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/conversations_activity_menu_contacts"
android:showAsAction="ifRoom|withText"
android:title="@string/contacts" />
</menu>
回答by arober11
Hit the same issue, after an hour or so of playing the issue was tracked down to a single quote " ' ", being present in a resource . Removed the quote and the error went away.
遇到同样的问题,在玩了一个小时左右后,问题被追踪到一个单引号“'”,存在于资源中。删除了引用,错误就消失了。
回答by Anup Cowkur
AAPT errors are sometimes caused by insufficient memory for eclipse to run in. See:
AAPT 错误有时是由于 eclipse 运行的内存不足导致的。参见:
How to diagnose "Error executing aapt" error in Eclipse?
For the second part of your problem, see this:
对于问题的第二部分,请参阅: