java.lang.RuntimeException: WakeLock under-locked C2DM_LIB

Rookie picture Rookie · Aug 27, 2012 · Viewed 39.1k times · Source

I have uploaded my application on google play but users have reported the following exception

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.

Answer

fasti picture fasti · Feb 19, 2013

You didn't post your code, so I don't know if you've already done what I will suggest here, but I also had that exception and all I added to fix it was a simple "if" to make sure the WakeLock is actually being held, before trying to release it.

All I added in my onPause was this "if" statement (before the "release()"):

if (mWakeLock.isHeld())
    mWakeLock.release();

and the exception was gone.