Android 为什么我收到错误“通道不可恢复地损坏,将被处理!”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12459719/
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
Why I am Getting Error 'Channel is unrecoverably broken and will be disposed!'
提问by uncle Lem
When I try to launch my AndEngine Activity, I get this error:
当我尝试启动我的AndEngine Activity 时,我收到此错误:
ERROR/InputDispatcher(21374): channel '4122e148 my.package.AcGame (server)' ~ Channel is unrecoverably broken and will be disposed!
The app doesn't crash, but there's a black screen and the device doesn't react to pressing the 'back' or 'home' buttons.
该应用程序不会崩溃,但会出现黑屏,并且设备对按下“返回”或“主页”按钮没有反应。
Does anyone know what the problem is?
有谁知道问题是什么?
回答by Lou Morda
One of the most common reasons I see that error is when I am trying to display an alert dialog or progress dialog in an activity that is not in the foreground. Like when a background thread that displays a dialog box is running in a paused activity.
我看到该错误的最常见原因之一是当我尝试在不在前台的活动中显示警报对话框或进度对话框时。就像显示对话框的后台线程在暂停的活动中运行一样。
回答by Roman Black
回答by Hymanie_Hung
Have you used another UI thread? You shouldn't use more than 1 UI thread and make it look like a sandwich. Doing this will cause memory leaks.
您是否使用过另一个 UI 线程?您不应使用超过 1 个 UI 线程并使其看起来像一个三明治。这样做会导致内存泄漏。
I have solved a similar issue 2 days ago...
我两天前解决了一个类似的问题......
To keep things short: The main thread can have many UI threads to do multiple works, but if one sub-thread containing a UI thread is inside it, The UI thread may not have finished its work yet while it's parent thread has already finished its work, this causes memory leaks.
简而言之:主线程可以有多个 UI 线程来完成多项工作,但如果其中包含一个包含 UI 线程的子线程,则 UI 线程可能尚未完成其工作,而其父线程已完成其工作工作,这会导致内存泄漏。
For example...for Fragment & UI application...this will cause memory leaks.
例如...对于 Fragment & UI 应用程序...这将导致内存泄漏。
getActivity().runOnUiThread(new Runnable(){
public void run() {//No.1
ShowDataScreen();
getActivity().runOnUiThread(new Runnable(){
public void run() {//No.2
Toast.makeText(getActivity(), "This is error way",Toast.LENGTH_SHORT).show();
}});// end of No.2 UI new thread
}});// end of No.1 UI new thread
My solution is rearrange as below:
我的解决方案是重新排列如下:
getActivity().runOnUiThread(new Runnable(){
public void run() {//No.1
ShowDataScreen();
}});// end of No.1 UI new thread
getActivity().runOnUiThread(new Runnable(){
public void run() {//No.2
Toast.makeText(getActivity(), "This is correct way",Toast.LENGTH_SHORT).show();
}});// end of No.2 UI new thread
for you reference.
供你参考。
I am Taiwanese, I am glad to answer here once more.
我是台湾人,很高兴再次在这里回答。
回答by codezjx
You can see the source code about this output here:
您可以在此处查看有关此输出的源代码:
void InputDispatcher::onDispatchCycleBrokenLocked(
nsecs_t currentTime, const sp<Connection>& connection) {
ALOGE("channel '%s' ~ Channel is unrecoverably broken and will be disposed!",
connection->getInputChannelName());
CommandEntry* commandEntry = postCommandLocked(
& InputDispatcher::doNotifyInputChannelBrokenLockedInterruptible);
commandEntry->connection = connection;
}
It's cause by cycle broken locked...
这是由循环破坏锁定引起的...
回答by ishitcno1
I got similar error (my app crashes) after I renamed something in strings.xml
and forgot to modify other files (a preference xml resource file and java code).
在我重命名某些内容strings.xml
并忘记修改其他文件(首选项 xml 资源文件和 java 代码)后,我遇到了类似的错误(我的应用程序崩溃)。
IDE (android studio) didn't showed any errors. But, after I repaired my xml files and java code, app ran okay. So, maybe there are some small mistakes in your xml files or constants.
IDE (android studio) 没有显示任何错误。但是,在我修复了我的 xml 文件和 java 代码后,应用程序运行正常。因此,也许您的 xml 文件或常量中存在一些小错误。
回答by yangzx
I had the same problem. Mine was due to a third jar, but the logcat did not catch the exception, i solved by update the third jar, hope these will help.
我有同样的问题。我的原因是第三个 jar,但 logcat 没有捕获异常,我通过更新第三个 jar 解决了,希望这些会有所帮助。
回答by Kapil Bhagia
I had the same problem. To solve the error: Close it on the emulator and then run it using Android Studio.
我有同样的问题。解决该错误:在模拟器上关闭它,然后使用 Android Studio 运行它。
The error happens when you try to re-run the app when the app is already running on the emulator.
当应用程序已经在模拟器上运行时,当您尝试重新运行应用程序时会发生错误。
Basically the error says - "I don't have the existing channel anymore and disposing the already established connection"as you have run the app from Android Studio again.
基本上错误说 - “我不再拥有现有频道并处理已经建立的连接”,因为您再次从 Android Studio 运行该应用程序。
回答by David Martínez Pérez
I was having the same problem too. In my case was caused when trying to reproduce videos with a poor codification (demanded too much memory). Thishelped me to catch the error and request another version of the same video. https://stackoverflow.com/a/11986400/2508527
我也遇到了同样的问题。在我的情况下,是在尝试复制编码不佳的视频(需要太多内存)时引起的。 这有助于我发现错误并请求同一视频的另一个版本。 https://stackoverflow.com/a/11986400/2508527
回答by amadosi
I had the same problem but mine was Due To an Android database memory leak. I skipped a cursor. So the device crashes so as to fix that memory leak. If you are working with the Android database check if you skipped a cursor while retrieving from the database
我有同样的问题,但我的是由于 Android 数据库内存泄漏。我跳过了一个光标。所以设备崩溃以修复内存泄漏。如果您正在使用 Android 数据库,请检查在从数据库中检索时是否跳过了游标
回答by mallik
It happened for me as well while running a game using and-engine. It was fixed after i added the below code to my manifest.xml. This code should be added to your mainactivity.
在使用 and-engine 运行游戏时,我也遇到了这种情况。在我将下面的代码添加到我的 manifest.xml 后,它被修复了。应将此代码添加到您的主要活动中。
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|mcc|mnc"