ViewGroup.resetResolvedTextDirection 中的 Android StackOverflowError

发布于 2025-01-03 03:14:13 字数 697 浏览 2 评论 0原文

我刚刚去 android 市场发布我的应用程序的更新,并注意到现有安装报告了一些新错误。虽然我可以理解(并尝试做一些事情)其中的大多数,但这一点让我相当困惑:

java.lang.StackOverflowError
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
... this line repeats about 200 times or so ...

这就是全部 - 没有任何其他信息。

我完全不知道从哪里开始调查这个问题。任何想法都将不胜感激。

I just went to android market to publish an update to my app and noticed there a few new errors reported from existing installs. While I can understand (and attempt to do something about) most of them, this one leaves me rather puzzled:

java.lang.StackOverflowError
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
at android.view.ViewGroup.resetResolvedTextDirection(ViewGroup.java:5131)
... this line repeats about 200 times or so ...

This is all there is - no other information of any kind.

I'm totally stumped as to where to start investigating this. Any ideas are greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

⒈起吃苦の倖褔 2025-01-10 03:14:13

这似乎是 ICS 中添加的方法,所以它是 4.0 及以上版本。查看 代码 看起来你的层次结构中有某种视图循环,因为它显然child.resetResolvedTextDirection(); 行执行此操作。换句话说,布局中的一个 ViewGroup 类已以某种方式作为子级添加到其自身的某个位置。

That appears to be a method added in ICS, so it's 4.0 and over. Looking at the code it seems like you have some kind of view loop in your hierarchy since it's apparently the child.resetResolvedTextDirection(); line doing it. In other words, one of your ViewGroup classes in your layout has somehow gotten added as a child to itself somewhere down the line.

明天过后 2025-01-10 03:14:13

我找到了问题所在。在我看来,这就像 Android 中的一个错误,当视图的 visibility 显式设置为 VISIBLE 但视图本身和视图的父级未添加到主视图时,就会出现该错误。看法。

我最终通过将有问题的 ListView 添加到 XML 而不是在代码中创建它并将代码 setVisibility(View.VISIBLE) 移动到将整个视图添加到主视图之后解决了这个问题(即父级层次结构可以从每个子级一直追溯到开始)。

至少我不会再收到这个错误了。

I tracked down the problem. It seems to me like a bug in Android, which is exhibited when a View's visibility is explicitly set to VISIBLE but the view itself and the view's parent is not added to the main view.

I finally got around the problem by adding the ListView in question to XML instead of creating it in the code and moving the code setVisibility(View.VISIBLE) to after the entire view is added to the main view (i.e. parent hierarchy can be traced from each child all the way to the beginning).

At least I'm not getting this error any more.

痞味浪人 2025-01-10 03:14:13

问题是当您膨胀视图时 inflater.inflate(R.layout.view_topic, this);
并且该视图的父级仍然不可见/渲染到舞台上。

确保在父级可见或调用后渲染它

View child = inflater.inflate(R.layout.view_topic, null); // null will give warning but it wont throw an exception
        this.addView(child);

The issue is when you inflate the view such that inflater.inflate(R.layout.view_topic, this);
and the parent of this view is still not visible / rendered on to the stage.

Make sure you render it after the parent is visible or call

View child = inflater.inflate(R.layout.view_topic, null); // null will give warning but it wont throw an exception
        this.addView(child);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文