I am using android studio, and followed the basic tutorials with android ndk. I also get the simple projects working.
Question:
My native lib returns a simple string. The file MyLibrary.cpp is within the jni folder, its working and looks like this:
#include "de_rownage_ndklib_MyNDK.h"
JNIEXPORT jstring JNICALL Java_de_rownage_ndklib_MyNDK_getMyString (JNIEnv *env, jobject)
{
return(*env).NewStringUTF("My Lib");
}
Now I would like to use a class like here: Scanning and Editing Android App Memory Values Programmatically, do I have to put it in a JNIEXPORT jint wrapper? This would not make sense to me. The JNI seems to be a an interface for calling c++ code in Java. It seems like i can not create a new memory.cpp file and call it in java without the JNIEXPORT stuff?
I ve also seen sth like this:
JNI (Directory) -> NDK_MyFunc.c
In the Memory.java (Activity-Class)
public String execNDK(String params) {
String[] commands = new String[2];
commands[0] = "chmod 777 /data/data/com.android.test/NDK_MyFunc";
commands[1] = "/data/data/com.android.test/NDK_MyFunc " + params;
return shell.execute(commands, false);
}
How is this working? Is it working? Does the file get compiled on the android system and executed? What I am trying to do is executing the main() function above, within my android app.