[英]Resolving java.lang.Throwable exception in an android
I am working on an android application which has a sqlite database. 我正在使用具有sqlite数据库的android应用程序。 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.
我不确定为什么会发生此异常,但是我想它与sqlite操作有关。 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? 谁能解释这个异常何时发生以及如何解决?
Like the log says: 就像日志说:
A resource was acquired at attached stack trace but never released.
在附加的堆栈跟踪中获取了资源,但从未释放过。 See java.io.Closeable for information on avoiding resource leaks.
有关避免资源泄漏的信息,请参见java.io.Closeable。
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.
当资源被垃圾回收并且它没有被关闭时,将显示该消息。
In your case, we can see that the resource is a ParcelFileDescriptor
, and it was created automatically by the IBackupAgent$Stub.onTransact()
method (ie, when your BackupAgent is getting a call through binder). 在您的情况下,我们可以看到该资源是一个
ParcelFileDescriptor
,它是由IBackupAgent$Stub.onTransact()
方法自动创建的(即,当您的BackupAgent通过活页夹获得调用时)。
The log should disappear if you make sure to close the ParcelFileDescriptors passed to your BackupAgent subclass. 如果您确保关闭传递给BackupAgent子类的ParcelFileDescriptors,则日志应消失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.