在Android解决java.lang.Throwable的异常 [英] Resolving java.lang.Throwable exception in an android

查看:4857
本文介绍了在Android解决java.lang.Throwable的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个Android应用程序有一个SQLite数据库。写code。在我的应用程序与数据库操作后,我得到下面的异常。虽然我的应用程序不会停止/崩溃,但我想知道如何解决这个例外。我不知道为什么这个异常发生,但我想它必须与SQLite的操作。我关闭了所有的数据流,连接和光标的建议。下面是堆栈跟踪:

I am working on an android application which has a sqlite database. After writing the code in my app related to database operation, I am getting below exception. Though my application doesn't stop/crash, but I want to know how to resolve this exception. I am not sure why this exception is occurring, but I suppose it has to do with sqlite operations. I have closed all streams, connections and cursors as recommended. Below is the stack trace:

689-698/? E/StrictMode﹕ A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
java.lang.Throwable: Explicit termination method 'close' not called
        at dalvik.system.CloseGuard.open(CloseGuard.java:184)
        at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java:180)
        at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:916)
        at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:906)
        at android.app.IBackupAgent$Stub.onTransact(IBackupAgent.java:57)
        at android.os.Binder.execTransact(Binder.java:446)
04-24 08:49:21.127      689-698/? E/StrictMode﹕ A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
java.lang.Throwable: Explicit termination method 'close' not called
        at dalvik.system.CloseGuard.open(CloseGuard.java:184)
        at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java:180)
        at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:916)
        at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:906)
        at android.app.IBackupAgent$Stub.onTransact(IBackupAgent.java:64)
        at android.os.Binder.execTransact(Binder.java:446)
04-24 08:49:21.129      689-698/? E/StrictMode﹕ A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
java.lang.Throwable: Explicit termination method 'close' not called
        at dalvik.system.CloseGuard.open(CloseGuard.java:184)
        at android.os.ParcelFileDescriptor.<init>(ParcelFileDescriptor.java:180)
        at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:916)
        at android.os.ParcelFileDescriptor$1.createFromParcel(ParcelFileDescriptor.java:906)
        at android.app.IBackupAgent$Stub.onTransact(IBackupAgent.java:71)
        at android.os.Binder.execTransact(Binder.java:446)

任何人都可以请解释这是否异常发生,以及如何解决它的时候?

Could anyone please explain when does this exception occur and how to resolve it?

推荐答案

像日志说:

一个资源收购,在连接的堆栈跟踪,但从来没有公布过。见java.io.Closeable的信息,避免资源泄漏。

A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.

显式的终止方法'关闭'不叫

Explicit termination method 'close' not called

请注意,调用堆栈显示了资源是的的。该消息被打印时,垃圾回收资源,并注意到它没有关闭。

Note that the callstack shows where the resource was created. The message is printed when the resource is garbage-collected and it notices that it wasn't closed.

在你的情况,我们可以看到,资源是 ParcelFileDescriptor ,并且它自动创建的 IBackupAgent $ Stub.onTransact() 方法(例如,当您BackupAgent越来越通过粘合剂的电话)。

In your case, we can see that the resource is a ParcelFileDescriptor, and it was created automatically by the IBackupAgent$Stub.onTransact() method (i.e., when your BackupAgent is getting a call through binder).

如果你一定要收传递给你的BackupAgent子类ParcelFileDescriptors日志应该消失。

The log should disappear if you make sure to close the ParcelFileDescriptors passed to your BackupAgent subclass.

这篇关于在Android解决java.lang.Throwable的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆