问题描述
我已经上传我的谷歌应用程序发挥,但用户报告以下异常
I have uploaded my application on google play but users have reported the following exception
java.lang.RuntimeException的:WakeLock下锁定C2DM_LIB 。当我尝试释放 WakeLock
发生此异常。谁能告诉可能是什么问题。
java.lang.RuntimeException: WakeLock under-locked C2DM_LIB. This exception occurs when I try to release the WakeLock
. Can anyone tell what could be the problem.
推荐答案
我在新的GCM图书馆追溯到相同的异常了。其实老C2DM的Android库有同样的错误,死机一样,和谷歌一直没有固定它。我可以通过我们的统计数据看,约0.1%的用户遇到此崩溃。
I have traced same exception in new GCM Library too. Actually old C2DM Android library have same error, same crash, and Google hasn't fixed it yet. As I can see by our statistics, about 0.1% of users experiencing this crash.
我的调查显示,问题是不正确的释放在GCM库网 WakeLock
,当库尝试释放 WakeLock
持有什么(内部锁定计数器变为负)。
My investigations shows that problem is in incorrect releasing of network WakeLock
in GCM library, when library tries to release WakeLock
that holds nothing (internal lock counter becomes negative).
我很满足于简单的解决方案 - 正好赶上这个例外,什么也不做,因为我们并不需要做任何额外的工作,然后我们wakelock保持什么
I was satisfied with simple solution - just catch this exception and do nothing, because we don't need to do any extra job then our wakelock hold nothing.
为了做到这一点,你需要导入GCM库源代码在你的项目,而不是已编译的.jar
文件。您可以在* $ Android_SDK_Home $ /演员/谷歌/ GCM / GCM客户端/ src目录*文件夹(你需要使用的Android SDK管理器首先下载)。
In order to do this you need to import GCM library sources in your project, rather than already compiled .jar
file. You can find GCM library sources under "*$Android_SDK_Home$/extras/google/gcm/gcm-client/src*" folder (you need to download it first using Android SDK Manager).
接下来打开 GCMBaseIntentService
类,发现行
sWakeLock.release();
和使用的try-catch包围它。
and surround it with try-catch.
这应该是这样的:
synchronized (LOCK) {
// sanity check for null as this is a public method
if (sWakeLock != null) {
Log.v(TAG, "Releasing wakelock");
try {
sWakeLock.release();
} catch (Throwable th) {
// ignoring this exception, probably wakeLock was already released
}
} else {
// should never happen during normal workflow
Log.e(TAG, "Wakelock reference is null");
}
}
更新:Alternativally,如他的回答,您可以使用 mWakeLock.isHeld()
方法来检查是否wakelock实际持有此锁。
UPDATE:Alternativally, as suggested @fasti in his answer, you can use mWakeLock.isHeld()
method to check if wakelock actually holding this lock.
这篇关于java.lang.RuntimeException的:WakeLock下锁定C2DM_LIB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!