Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WakeLock under-locked GCM_LIB

My android app got crash report like below.(very rare)

java.lang.RuntimeException: WakeLock under-locked GCM_LIB
    at android.os.PowerManager$WakeLock.release(PowerManager.java:325)
    at android.os.PowerManager$WakeLock.release(PowerManager.java:300)
    at com.google.android.gcm.GCMBaseIntentService.onHandleIntent(GCMBaseIntentService.java:252)

Like java.lang.RuntimeException: WakeLock under-locked C2DM_LIB, I could try~catch or using isHeld()

but I'm not sure this is the best solution and I want to know why this is happening.

Some guess is that BroadcastReceiver and Service in different process like http://groups.google.com/group/cw-android/browse_thread/thread/9716bc101ce72fb4.

But is this even possible? I never used android:process in manifest, so BroadcastReceiver and Service should be in the same(main) process, shouldn't they?

like image 953
NoraBora Avatar asked Apr 04 '13 11:04

NoraBora


1 Answers

+NoraBora this is a bug from GCM lib that you included into your project. This bug is still there in r3 version of the gcm.jar

You can find more information in this Issue thread: https://code.google.com/p/android/issues/detail?id=36364#makechanges

As Mark said:

Yup, ran into those with WakefulIntentService. If you're willing to create your own fork of GCMBaseIntentService, wrap the WakeLock release() call in a check of isHeld() to avoid this crash.

like image 180
StErMi Avatar answered Oct 19 '22 16:10

StErMi