Android ICS : JNI error attempt to use stale local reference 0x1

前端 未结 6 639
终归单人心
终归单人心 2021-02-02 11:50

After upgrading my phone to android 4.03 ics my game dosent open anymore ,it just closes without any error messege on deviCe and with this on eclipse

04-02 16:         


        
6条回答
  •  悲&欢浪女
    2021-02-02 12:21

    While Ernest's answer is technically correct, a stale local reference to something like 0x1 should hint you that the Java VM is trying to use something that's not a Java object as a Java object.

    For example, let's assume your JNI function is:

    JNI_EXPORT jboolean foobar(JNIEnv *env, jobject self) {
      ...
      return JNI_TRUE;
    }
    

    but you erroneously declare the Java counterpart as public native Boolean foobar() instead of public native boolean foobar().

    It's an easy mistake to make, since the only difference between boolean and Boolean is capitalization.

    • boolean, a primitive type, is represented in JNI as boolean
    • java.lang.Boolean, known also as Boolean, is a class type that is represented in JNI as jobject

    Upon return from foobar, the Java VM will treat the JNI_TRUE value (0x1) as if it referred to a java.lang.Boolean object, which will result in this fatal error.

提交回复
热议问题