安卓ICS:JNI错误试图使用过时的本地引用为0x1错误、ICS、JNI

2023-09-05 02:05:42 作者:Midsummer. 仲夏

升级我的手机到Android 4.03集成电路我的游戏dosent开了之后,它只是关闭不会对设备的任何错误messege以及与此有关日食

  04-02 16:55:27.672:E / dalvikvm(26884):JNI错误(应用程序错误):试图使用过时的本地引用为0x1
04-02 16:55:27.672:E / dalvikvm(26884):VM中止
 

我的游戏主要是writen在Java中,但有些部分是用C并且那是我认为 问题是(不是很难搞清楚,因为它说JNI错误:))

当然,我不知道问题出在哪里,所以我不给任何$ C $的C

我没有对这个问题的Andr​​oid 2.3

我不知道是否有帮助,但我得到这个错误太多,有时

  04-02 16:55:26.061:E /的Adreno200-ES11(26884):其中,qglDrvAPI_glTexImage2D:1913年计算值:GL_STACK_UNDERFLOW
 

解决方案

虽然欧内斯特的答案在技术上是正确的,过时的本地引用类似为0x1应该暗示你,Java虚拟机试图使用的东西,这不是一个Java对象作为一个Java对象。

Android JNI

例如,假设你的JNI功能是:

  JNI_EXPORT jboolean foobar的(JNIEnv的* ENV,jobject个体经营){
  ...
  返回JNI_TRUE;
}
 

但你错误地宣布了Java对应的公共本地布尔foobar的()而不是公共本地布尔foobar的()

这是一个容易犯的错误,因为在布尔布尔是资本唯一的区别。

布尔,一个基本类型,重新psented在JNI为$ P $ 布尔 java.lang.Boolean中的,又称布尔,是一个类类型,它重新presented在JNI为 jobject

在返回从 foobar的,Java虚拟机将把 JNI_TRUE 值(为0x1),就好像它指的是一个 java.lang.Boolean中的的对象,这将导致这种致命的错误。

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:55:27.672: E/dalvikvm(26884): JNI ERROR (app bug): attempt to use stale local reference 0x1
04-02 16:55:27.672: E/dalvikvm(26884): VM aborting

My game is mainly writen in java but some parts are in c and thats were i think the problem is (not very hard to figure out since its saying JNI ERROR :) )

Of course i dont know where the problem is so i dont give any code

I didnt had this problem on android 2.3

I dont know if it helps but i get this error too sometimes

04-02 16:55:26.061: E/Adreno200-ES11(26884): <qglDrvAPI_glTexImage2D:1913>: GL_STACK_UNDERFLOW

解决方案

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.

 
精彩推荐
图片推荐