Thursday, July 12, 2012

Getting this? E/dalvikvm( 6037): JNI ERROR (app bug): attempt to use stale weak global reference 0xb

Seeing this in your Android code?

E/dalvikvm( 6037): JNI ERROR (app bug): attempt to use stale weak global reference 0xb

Make sure you're not:

a) Calling back into java from javascript in a WebView, and then b) Dereferencing a null pointer in Java.

Notice that this problem has nothing to do with any of your JNI code.

2 comments:

Unknown said...

Hi James,

I am getting the same error. I am also calling methods from javascript to java. But it was working fine, I ma not sure what happened. It works fine for previous version of android than ICS. What might be an issue ?

JM said...

I edited the entry a bit to make it clear that (in my case) it was because I did both A and B at the same time. My suggestion would be to add a level of indirection around the java call and make the original call in a try-catch block. My guess is that this is a symptom of an uncaught exception when you call java from javascript.