java-native-interface

JNI: intercepting native methods outputs

╄→гoц情女王★ 提交于 2020-01-15 07:06:27
问题 currently i am working on a project where i need to intercept the results of java native method calls for further analysis. There are multiple ways to achieve that but the way of my choice is: at native binding time, re-bind the addresses of java native methods to the address of my own wrapper-function, which would call the initial native function by itself and then return its result while intercepting the returned variable. The wrapper function should be generic, meaning it would handle the

Android NDK wifi example

别来无恙 提交于 2020-01-15 05:55:51
问题 I want to use features of WIFI with the help of c code by using NDK in android. I don't want to use Java API for WIFI. I tried on Google as well as on stackoverflow, but I didn't got any example for it. I am just wondering , let me know is it possible or not ? I have found some android API for WIFI. but I haven't any knowledge of implementation. 回答1: You may wanna look at libcurl, but not quite sure. Because I am developing games using cocos2d-x (which is using android ndk), and libcurl is

android bitmap pixel format for glTexImage2D

妖精的绣舞 提交于 2020-01-14 14:49:07
问题 I'm trying to load textures to use with NDK OpenGL from Java with the Bitmap class. It works, but I'm having problems with the pixel format. First, in Java, I load a bitmap from the assets folder like this: Bitmap bitmap = BitmapFactory.decodeStream(amgr.open(path)); return bitmap.copy(Bitmap.Config.ARGB_8888, false); the bitmap config does not have an option for RGBA channel order. [JNI things happen here] Using GLES 1, I then buffer the texture like so: glTexImage2D(GL_TEXTURE_2D, 0, GL

android bitmap pixel format for glTexImage2D

倖福魔咒の 提交于 2020-01-14 14:49:06
问题 I'm trying to load textures to use with NDK OpenGL from Java with the Bitmap class. It works, but I'm having problems with the pixel format. First, in Java, I load a bitmap from the assets folder like this: Bitmap bitmap = BitmapFactory.decodeStream(amgr.open(path)); return bitmap.copy(Bitmap.Config.ARGB_8888, false); the bitmap config does not have an option for RGBA channel order. [JNI things happen here] Using GLES 1, I then buffer the texture like so: glTexImage2D(GL_TEXTURE_2D, 0, GL

compile ICS/JB camera application - native library jni-mosaic error

核能气质少年 提交于 2020-01-14 14:19:48
问题 I would like to use the Panorama mode that the ICS/JB camera application has. I've downloaded the source code (with resources) and managed to solve all code compilation errors but as soon as I start the application on my device (running JB), I get this error: 10-25 14:42:53.617: E/AndroidRuntime(23147): FATAL EXCEPTION: GLThread 2586 10-25 14:42:53.617: E/AndroidRuntime(23147): java.lang.UnsatisfiedLinkError: Native method not found: com.app.camera.panorama.MosaicRenderer.reset:(IIZ)V 10-25

How to unload a dll which gets loaded by System.load(path to dll)

眉间皱痕 提交于 2020-01-14 14:18:09
问题 Is there any way to unload a DLL which gets loaded in the application using System.load() API call. 回答1: You have to use a separate ClassLoader to load the dll. The dll is only bound to the ClassLoader it was loaded with. When the ClassLoader isn't used anymore (means no references to the ClassLoader exist), the garbage collector will free your ClassLoader and unload your dll. 来源: https://stackoverflow.com/questions/1491043/how-to-unload-a-dll-which-gets-loaded-by-system-loadpath-to-dll

Android NDK app failed to load library

心不动则不痛 提交于 2020-01-14 14:14:50
问题 My native library code: #include <string.h> #include <jni.h> jstring Java_com_mindtherobot_samples_ndkfoo_NdkFooActivity_invokeNativeFunction(JNIEnv* env, jobject javaThis) { return env->NewStringUTF("Hello from native code!"); } Android.mk: LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := libpacman LOCAL_SRC_FILES := main.cpp LOCAL_CFLAGS := -DANDROID_NDK LOCAL_LDLIBS := -llog include $(BUILD_SHARED_LIBRARY) MainActivity.java: public class MainActivity extends Activity {

hold in “Trying to load lib” and no return for ever

夙愿已清 提交于 2020-01-14 12:54:30
问题 I have a old app written by C++, I am trying to port it to android , and debug it with eclipse, but the project is stopping with an error message : 10-03 12:21:55.344: D/dalvikvm(15262): Trying to load lib /data/data/com.android.test/lib/libtest.so 0x40effa48 The application just stops without giving any other message. I don't know how to do continue. 回答1: I have the same problem but it is caused by this bug So simply remove NDK_TOOLCHAIN_VERSION=4.7 from your Application.mk i have this only

How to use Runtime.getRuntime().exec(“cmd”)

左心房为你撑大大i 提交于 2020-01-14 09:15:26
问题 In my application I'm trying to execute a native code which is present on my SD card. File sdCard = getExternalFilesDir(null); // directory where native file is placed String nativeFile = "nativeFile"; String cmd = "shell /system/bin/chmod 0777 " + sdCard.getAbsolutePath() + "/" + nativeFile; Process proc = Runtime.getRuntime().exec(cmd); But as soon as Runtime.getRuntime().exec(cmd) is executed, it throws error: java.io.IOException: Error running exec(). Command: [shell, /system/bin/chmod,

Android JNI APK Packing

本小妞迷上赌 提交于 2020-01-14 07:46:37
问题 I have implemented a JNI android application. This application requires a few additional 'Shared Libs' to be packed as part of the APK. Using Ecplise, I have added these libs to the project's '/libs/armeabi' folder. However, when launching the application (through the integrated debugger), my added 'Shared Libs' are removed from the 'armeabi' folder. How can I prevent these additional libs from being removed? How can I make sure the additional required SOs are packed in the APK? 回答1: You don