我正在使用crashlytics跟踪我的应用程序的崩溃。有一个bug很难弄清楚。来自crashlytics的堆栈跟踪如下:
java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
at android.view.InputChannel.nativeReadFromParcel(InputChannel.java)
at android.view.InputChannel.readFromParcel(InputChannel.java:148)
at android.view.InputChannel$1.createFromParcel(InputChannel.java:39)
at android.view.InputChannel$1.createFromParcel(InputChannel.java:36)
at com.android.internal.view.InputBindResult.<init>(InputBindResult.java:62)
at com.android.internal.view.InputBindResult$1.createFromParcel(InputBindResult.java:102)
at com.android.internal.view.InputBindResult$1.createFromParcel(InputBindResult.java:99)
at com.android.internal.view.IInputMethodManager$Stub$Proxy.windowGainedFocus(IInputMethodManager.java:851)
at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:1292)
at android.view.inputmethod.InputMethodManager.onWindowFocus(InputMethodManager.java:1518)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3550)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5293)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(NativeStart.java)我知道关于这个here还有一个类似的问题。但这有一点不同。根据crashlytics的统计数据,这起事故主要发生在三星android手机上。
我是android的新手,我不知道为什么会发生这种崩溃,也不知道如何修复这种崩溃。
任何建议都将不胜感激。
发布于 2015-01-07 04:54:53
认为这是一个非常广泛的领域,可能会有很多情况可以触发这个系统级别的异常。但是也许这个例子是如何在一个特定的项目中修复的,它可以帮助某人。
我也经历过类似的例外:
三星手机"Could not read input channel file descriptors from parcel":
java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
at android.view.InputChannel.nativeReadFromParcel(Native Method)
at android.view.InputChannel.readFromParcel(InputChannel.java:148)
at android.view.IWindowSession$Stub$Proxy.addToDisplay(IWindowSession.java:690)
at android.view.ViewRootImpl.setView(ViewRootImpl.java:525)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:269)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.widget.Toast$TN.handleShow(Toast.java:402)
at android.widget.Toast$TN$1.run(Toast.java:310)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5103)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)它发生在一个大型的老工程中,我得到了维护和这个浮动的错误发生后,只有几个小时。我花了相当长的时间在上面,也阅读了一些相关的答案,除了这是Android的系统级错误之外,没有任何线索,内存中应该有一些额外的数据或对象或大对象的复制,等等:
https://code.google.com/p/android/issues/detail?id=32470
我最后能想到的是SoundPool。它在这个项目中使用不多--不超过10种不同的声音不时播放。
但这是根本原因!有时会有来自"unable to load sample (null)".的浮动异常。它帮助我们认识到SoundPool被错误地使用了:
public void play(int rscId) {
...
final int soundId = soundPool.load(mContext, rscId, 1);
...
soundPool.play(soundId, volume, volume, 5, 0, 1f);这样就产生了新的id,并且每次应用程序都重新加载了声音资源,称为play声音方法!在经过一定时间之后,一些不相关的异常开始发生,直到应用程序与"Could not read input channel file descriptors from parcel"异常崩溃。
有趣的是,其中一个与此无关的例外是:
"ExceptionHandled in unable to open database file (code 14)":
ExceptionHandled in unable to open database file (code 14)
android.database.sqlite.SQLiteCantOpenDatabaseException:
unable to open database file (code 14)
at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow
(Native Method)
at android.database.sqlite.SQLiteConnection.executeForCursorWindow
(SQLiteConnection.java:845)当然,这既与数据库无关,也与祝酒词/包裹无关。解决这种特殊情况的方法非常容易:就像Android文档中所建议的那样,只需预加载所有声音:
http://developer.android.com/reference/android/media/SoundPool.html
“加载逻辑遍历调用适当的SoundPool.load() function的声音列表。这通常应该在过程的早期完成,以便在播放需要之前将音频解压缩为原始的PCM格式。
一旦加载了声音并开始播放,应用程序就可以通过调用SoundPool.play()来触发声音。“
因此,我移除了soundPool.load() out from play() method和例外:
"Could not read input channel file descriptors from parcel"和例外"unable to open database file (code 14)"一样都走了。
public void play(int soundId) {
...
soundPool.play(soundId, volume, volume, 5, 0, 1f);当不再需要soundPool.release(); soundPool = null时,也应该调用它。也许它也会对这些例外情况产生影响,请参阅这里的详细信息。
Could not read input channel file descriptors from parcel
很可能这不是最初问题的确切情况,但希望它能提供一些信息来进一步挖掘。例如,寻找其他异常、吞并异常或错误的文件/数据处理。
发布于 2016-03-24 16:22:54
我一直在寻找答案,比如其他人在这个例外情况下面临的问题。
在我看来,这种崩溃也可以由正常的TextView或EditText触发,后者与InputMethodManager一起工作。
java.lang.RuntimeException: Could not read input channel file descriptors from parcel.
at android.view.InputChannel.nativeReadFromParcel(Native Method)
at android.view.InputChannel.readFromParcel(InputChannel.java:148)
at android.view.InputChannel$1.createFromParcel(InputChannel.java:39)
at android.view.InputChannel$1.createFromParcel(InputChannel.java:36)
at com.android.internal.view.InputBindResult.<init>(InputBindResult.java:68)
at com.android.internal.view.InputBindResult$1.createFromParcel(InputBindResult.java:112)
at com.android.internal.view.InputBindResult$1.createFromParcel(InputBindResult.java:109)
at com.android.internal.view.IInputMethodManager$Stub$Proxy.startInput(IInputMethodManager.java:697)
at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:1407)
at android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:1518)
at android.view.inputmethod.InputMethodManager.restartInput(InputMethodManager.java:1286)
at android.widget.TextView.setText(TextView.java:4718)
at android.widget.TextView.setText(TextView.java:4656)
at android.widget.TextView.append(TextView.java:4330)
at android.widget.TextView.append(TextView.java:4320)
...当TextView附加文本时,它将生成文本到Editable,并启动InputMethodManager。但是此时,InputMethod过程中出现了一些问题,导致无法创建从包中读取错误的InputBindResult。
在这种情况下,解决方法非常简单:不要直接调用文本视图上的追加,而是使用StringBuilder或SpannableStringBuilder构建文本并调用TextView.setText(text)!
发布于 2017-02-02 22:15:53
以前的用户评论说,这可能是一个很难追踪的错误。我是通过在一个TextView循环中构建一个自定义警报对话框(包含多个while对象)来实现这一目的的,这个对话框是一个if语句。应用程序在显示对话框(Es)之前崩溃。
https://stackoverflow.com/questions/25132509
复制相似问题