简体   繁体   English

解决Android中的java.lang.Throwable异常

[英]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.

相关问题 java.lang.Throwable:setStateLocked - java.lang.Throwable: setStateLocked JSONException无法转换为java.lang.Throwable - JSONException cannot be converted to java.lang.Throwable 为什么java.lang.Throwable是一个类? - why is java.lang.Throwable a class? java.lang.Throwable:RecyclerView中的addInArray - java.lang.Throwable: addInArray in RecyclerView java.lang.Throwable:ReferenceError:事件未定义 - java.lang.Throwable: ReferenceError: event is not defined 发生异常:java.lang.Throwable:javax.servlet.ServletException:过滤器[struts2]:无法初始化 - An exception occurred: java.lang.Throwable: javax.servlet.ServletException: Filter [struts2]: could not be initialized 将 <error-page> 在servlet 3.0+应用程序中捕获java.lang.throwable异常? - will <error-page> catch java.lang.throwable exception in servlet 3.0+ app? 杰克逊的readEntity将我的异常序列化为java.lang.Throwable而不是正确的Error异常 - Jackson's readEntity is serializing my Exceptions into java.lang.Throwable instead of the correct Error exception Android StrictMode java.lang.Throwable:未调用显式终止方法“关闭” - Android StrictMode java.lang.Throwable: Explicit termination method 'close' not called Java:重写的方法不会抛出“ java.lang.Throwable” - Java : Overridden method does not throw 'java.lang.Throwable'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM