JNI

Android and JNI real time clock

匿名 (未验证) 提交于 2019-12-03 08:50:26
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I got a problem with a mini Android application and the use of real time clock signals in a C (JNI) function. It seems like Android UI doesn't like real time signals from timers instanced in a C function. In the following PoC , a timer trigger a signal 5 times per second and if the signal is triggered while the UI is updating, the application crashes. If i don't start the timer => no crash If i don't put anything on UI => no crash I wrote this little PoC to evidence the behaviour. Java part just call the JNI function and put a button on

Android JNI exception handling

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need an exception handling implemented in JNI code. I am not good at jni and can't find any good example. So, please provide full example for this. This is what I am doing: jint JNI_OnLoad(JavaVM* vm, void* reserved) { jint result = -1; g_JavaVM = vm; if (vm->GetEnv((void **) &envLocal, JNI_VERSION_1_6) != JNI_OK) { return -1; } jclass clazz; **clazz = envLocal->FindClass("com/graphics/myclass/MyClass");** if (clazz == NULL) __android_log_print(ANDROID_LOG_ERROR, "MyClass", "clazz value is null"); g_clazz = (jclass) envLocal->NewGlobalRef

android Flurry integration with NDK app

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: My Android application comprises two parts: frontend written in Java and game written in C++ using NativeActivity NDK stuff. I have a problem integrating Flurry into my application. Flurry works fine from within Java part, but crashes from within C++. More specifically, call jni_env->FindClass("com/flurry/android/FlurryAgent"); results in ClassNotFoundException . jni_env variable is not broken because I am able to get some Intent params using it. FlurryAgent.jar is added to libs dir and into .classpath . I've even checked 'Order and Export'

Trouble calling on a Java method from a native thread using JNI (C++)

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a JNI problem which I hope someone can help me out with. I'm trying to call on a constructor of a Java class called LUSOutputJNI from a native thread. It keeps failing on FindClass(...) of this specific class. Here is the code: LOGE("1"); JNIEnv *env = NULL; LOGE("2"); int res = -1; res = g_vm->AttachCurrentThread(&env, NULL); if(env == NULL) { LOGE("env is NULL, AttachCurrentThread failed");; } if(res >= 0) LOGE("AttachCurrentThread was successful"); jclass clazz = NULL; jmethodID cid; jclass clazzESEngine; jmethodID callbackid;

NDK/JNI: identifying current thread

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In a JNI native method, is there a way to know the ID of the current thread without calling Java back? Thread-local storage would also work. EDIT: pthread.h is present in the NDK include folder... Does anyone know if Java threads correspond to POSIX ones in the NDK implementation? 回答1: Which ID are you interested in? A Dalvik thread dump includes this: "main" prio=5 tid=1 TIMED_WAIT | group="main" sCount=1 dsCount=0 obj=0x40017730 self=0x12798 | sysTid=3167 nice=0 sched=0/0 cgrp=default handle=-2146114456 | schedstat=( 358850000 275073000

Android NDK - NativeActivity vs JNI lib

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: two years ago i developed an Augmented Reality framework on android-7 (Eclair) . Since AR application are computationally intensive task, I developed a JNI c++ library used by a Java activity to render and register the virtual environment. The sensor readings acquired in Java are passed to the underline c++ library to compute the registration of the virtual environment. Tridimensional objects are rendered by a native draw function called from a GLSurfaceView . This results in a lot of JNI call. Now I would like to port the

Jabber.net on Unity/Android error (No JNI_OnLoad found in /system/lib/libc.so, skipping init)

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to create a Jabber (Jabber.net) chat client using Unity3D(Mono/C#) for iOS and Android. I got the client working in iOS (also runs well in Unity simulator). However, when running it on a Nexus 7 or HTC Desire it does not work. It does not crash, but does not connect either. It just produces the following error: D/dalvikvm(9368): No JNI_OnLoad found in /system/lib/libc.so 0x413b7270, skipping init This error is connected to the Connect method of my Jabber.net client: jc = new JabberClient(); ... // Setting up the jabberclient and

Android JNI DETECTED ERROR IN APPLICATION: JNI GetMethodID called with pending exception

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to run a Googles OCR Tesseract with my android project. I have already complied tesseract with android-ndk and am receiving this error after I try and run the android project. My environment is as follows Android 5.1.1 android-ndk-r10e for windows android-sdk-r22 For reference, I'm building from an example that is listed here Example Link Thanks in advance! Here is a snippet of my logcat result: I/DEBUG ( 182): Revision: '0' I/DEBUG ( 182): ABI: 'arm' I/DEBUG ( 182): pid: 20291, tid: 20337, name: JavaBridge >>> com.enterprisem

eclipse HttpServlet 类会报错

*爱你&永不变心* 提交于 2019-12-03 06:18:44
以前的eclipse因为更换电脑的位数,启动时会出现Failed to load the JNI shared library的错误,好像是和jdk位数(32位或64)有关系 重新copy了一个eclipse导进去项目遇到以下问题: 错误:HttpServlet 类会报错 解决方法:将tomcat——lib下的servlet-api.jar导进去或者copy到WEB-INF/lib下就ok了。 来源: oschina 链接: https://my.oschina.net/u/2483853/blog/516841

C和C++函数时的JNI使用区别

我是研究僧i 提交于 2019-12-03 05:31:19
Java调用C和C++函数时的JNI使用区别: 注意:jni.h头文件中对于***.c & ***.cpp采用不同的定义 在C的定义中,env是一个两级指针,而在C++的定义中,env是个一级指针 C形式需要对env指针进行双重deferencing,而且须将env作为第一个参数传给jni函数 jclass (JNICALL *GetObjectClass) (JNIEnv *env, jobject obj); jclass GetObjectClass(jobject obj) { return functions->GetObjectClass(this,obj); } 对于***.c 1.jclass test_class = (*env)->GetObjectClass(env, obj); 2.jfieldID id_num = (*env)->GetFieldID(env, test_class, "num", "I"); 对于 ***.cpp 1.jclass test_class = env->GetObjectClass(obj); 2.jfieldID id_num = env->GetFieldID(test_class, "num", "I"); 在 C 中, JNI 函数调用由“(*env)->”作前缀,目的是为了取出函数指针所引用的值。 在 C++ 中