Android/Eclipse StackOverflow 错误
每次我在 res 文件夹中添加 ab xml 布局时,都会弹出一个错误,指出 logo.xml 中出现问题:java.lang.StackOverflowError,当我单击“确定”时,Eclipse 会显示:
发生堆栈溢出错误。建议您退出 工作台。可能会发生后续错误并可能终止 工作台无警告。有关更多详细信息,请参阅 .log 文件。
您想退出工作台吗?
我不明白为什么。这很烦人和令人沮丧。我怎样才能修复它?
这是 logo.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageLogo"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:contentDescription="@string/desclogo"
android:scaleType="center"
android:src="@drawable/application_logo" />
</LinearLayout>
注意: 每次我在 /res 文件夹中添加 Android XML 文件时都会弹出该错误,有时甚至只是打开 /res 文件夹中的 xml 文件也会弹出该错误。
Everytime I add ab xml layout in the res folder, an error pops up saying that a problem has occurred in logo.xml: java.lang.StackOverflowError and when I click ok, Eclipse says:
A stack overflow error has occurred. You are recommended to exit the
workbench. Subsequent errors may happen and may terminate the
workbench without warning. See the .log file for more details.Do you want to exit the work bench?
I can't figure it out why. It's annoying and frustrating. How can I get fix it?
Here's logo.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageLogo"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:contentDescription="@string/desclogo"
android:scaleType="center"
android:src="@drawable/application_logo" />
</LinearLayout>
NOTE:
The error pops up everytime I add an Android XML file in the /res folder, and sometimes it pops up even just opening the xml file in the /res folder.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
刚刚遇到这个问题。当它要求关闭工作台时,回答“否”,转到打开的 XML 文件的图形视图,然后使用右上角的组合框更改主题。如果这不起作用,请尝试使用它周围的其他设置。一定是 Android 图形编辑器中的某种错误。
Just had this problem. When it asks to close the workbench, answer no, go to the graphical view of the open XML file, and change the theme using the combobox in the top right. If that doesn't work, try playing with the other settings around it. Must be some kind of bug in the Android graphical editor.
右键单击您的项目。
选择Android工具>添加支持库...
(将会出现一个进度条,瞧,它应该下载您需要的内容)
顺便说一句,您应该真正安装最新的 android-sdk 更新。从您的屏幕截图来看,您似乎还没有。
或者您也可以尝试此操作
确保 AndroidManifest.xml 中的 android:targetSdkVersion 值与 project.properties 中的 target=android- 匹配。如果这两个值不相同,则使用构建工具版本 19.0.0 进行构建将以 BufferOverflowException 结束。来源
这篇文章的评论还表明您需要至少定位 19 (android-19)。如果您的目标是 <<,此解决方案也适用,请发表评论。 19.
这就是我的项目的修复方式。相关的 AOSP 问题是#61710。
1 如果确实需要降级,则无需卸载构建工具19.0.0,只需安装18.1.1并在local.properties文件中添加sdk.buildtools=18.1.1即可。
Right-click on your project.
Select Android Tools > Add Support Libraries...
(a progress bar will appear, and voila it should download what you need)
By the way, you should really install the latest android-sdk update. From your screenshot, it doesn't look like you have yet.
Or you can try this too
Make sure that the value of android:targetSdkVersion in AndroidManifest.xml matches target=android- in project.properties. If these two values are not the same, building with build tools version 19.0.0 will end in the BufferOverflowException. Source
There is also some indication from comments on this post that you need to target at least 19 (android-19). Please leave a comment if this solution also works if your target is < 19.
This is how the fix looks for my project. The related AOSP issue is #61710.
1 If you really need to downgrade, you don't need to uninstall build tools 19.0.0, simply install 18.1.1 and add sdk.buildtools=18.1.1 to the local.properties file.