java-native-interface

C and Java through Jni

隐身守侯 提交于 2020-01-06 08:27:27
问题 I'm trying to call the java code from S. This method call: cls = (* env) -> FindClass (env, "org / libsdl / app / SDLActivity"); mid = (* env) -> GetStaticMethodID (env, cls, "play", "([Ljava / lang / String;) V"); (* env) -> CallVoidMethod (env, cls, mid); java method: public static void play () { track.write (bytes, 0, bytes.length); } Cause this error: 03-25 18:17:32.313: WARN / dalvikvm (655): JNI WARNING: JNI method called with exception raised 03-25 18:17:32.313: WARN / dalvikvm (655):

Heap Corruption - SEGV_MAPERR in Android Native code

谁都会走 提交于 2020-01-06 07:43:14
问题 I am trying to create a small library for stream AES encryption, I started my work based on Facebook Conceal project (https://github.com/facebook/conceal), just changing some things and improving the wrapper around the native to support ciphers with padding. It is working and it can decipher files without problems but I get random Heap Memory Corruptions when I work with large streams, and after a lot of time debugging I have been unable to find the error. Here is my code: https://gist.github

throw exception when Java JNI experiences segmentation fault

Deadly 提交于 2020-01-06 07:20:17
问题 We have code running JNI in a separate thread. We occasionally get segmentation faults while developing that we need to debug, but because the code is running in a separate thread the seg-fault isn't reported. Instead the thread essentially dies without warning making debugging difficult. I would like to be able to either detect a segmentation fault and/or throw an exception when a seg fault occurs so that we have some indication that a thread has died without warning. Is there any way to

How to call Jni object in Android Activity?

那年仲夏 提交于 2020-01-06 06:19:11
问题 I am making an Document Scanner. I'm using opencv for image processing. In camera view i'm bounding rectangle on largest contour. Processing part written in Native-lib.cpp. It is detecting largest contour properly. And now i want to capture only boudingRect which is written in native-lib.cpp. So i want object of native-lib in java class. help to get that. Native-lib.cpp extern "C" JNIEXPORT void JNICALL Java_prisca_ctest_OpenCvCamera_doWithMat(JNIEnv *env, jobject instance, jlong matAddrGr,

Parallel Processing with camera2 api android and opencvcamera2

半腔热情 提交于 2020-01-06 05:47:30
问题 I am developing an app where I want to process each frame from the camera and apply some Image processing algorithms on it. I am getting image feed from ImageReader inside onImageAvailable callback and passing it to my cpp code with JNI interface for further processing. This works fine until I perform heavy operations inside my cpp code, after that it starts adding delay and lag to camera preview. is it possible to process on feed images in parallel so I can achieve real-time results? I am

Setting up JNI in Android Studio 3

大城市里の小女人 提交于 2020-01-06 05:01:52
问题 I am using JNI in an Android Studio project I am working on. Currently, I have a C++ library that looks similar to this. #include <jni.h> ... extern "C" { JNIEXPORT jobject JNICALL Java_com_cerbyarms_cerbyarms_esra_camera_CameraActivity_FindFeatures(JNIEnv* env, jobject, jlong maskMat) { ... jclass rectClass = env->FindClass("org/opencv/core/Rect"); jmethodID rectID = env->GetMethodID(rectClass, "<init>", "(IIII)V"); return env->NewObject(rectClass, rectID, x, y, width, height); } } This

Gradle 2.5 Experimental : include .so library and call from JNI

不羁岁月 提交于 2020-01-06 02:57:10
问题 My problem is that I fail to find some proper documents/guides to follow in order to set up my environment correctly. Basically I am using Android Studio 1.3.2 (latest stable as of 22nd september 2015) with Gradle Experimental version 2.5. I followed Google official documentation here : http://tools.android.com/tech-docs/new-build-system/gradle-experimental but I find no help when it comes to JNI Libs. I tried many other solutions but they do not work because they seem to be obsolete. I have

JNA - EnumProcessModules() not returning all DLLs?

 ̄綄美尐妖づ 提交于 2020-01-05 22:17:34
问题 I trying to read coordinates from a game. This works perfectly fine, when using ReadProcessMemory on a HANDLE that I receive through OpenProcess, with the memory I find in CheatEngine. For example, if I know the float value in the running process is at 0x5AB38F68, I can read this. However, the address changes everytime the game restarts. It depends on a module called AkSoundEngine.dll. So basically the address would be at AkSoundEngine.dll+0x168F68. However, I cannot for the life of me find

JNA - EnumProcessModules() not returning all DLLs?

◇◆丶佛笑我妖孽 提交于 2020-01-05 22:16:13
问题 I trying to read coordinates from a game. This works perfectly fine, when using ReadProcessMemory on a HANDLE that I receive through OpenProcess, with the memory I find in CheatEngine. For example, if I know the float value in the running process is at 0x5AB38F68, I can read this. However, the address changes everytime the game restarts. It depends on a module called AkSoundEngine.dll. So basically the address would be at AkSoundEngine.dll+0x168F68. However, I cannot for the life of me find

Android NDK: Static library used is different than precompiled library specified

无人久伴 提交于 2020-01-05 14:59:54
问题 I build a C++ library manually using the Android SDK compiler. The result is libMyUtils.a. I'm using the following in my Java/JNI test application: LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := MyUtils LOCAL_SRC_FILES := ../../../../libs/libMyUtils.a include $(PREBUILT_STATIC_LIBRARY) LOCAL_MODULE := AndroidTests LOCAL_STATIC_LIBRARIES := MyUtils include $(BUILD_SHARED_LIBRARY) When I build the console shows the following: [armeabi] Install : libMyUtils.so => libs/armeabi