NDKは初めてです。
次の機能を持つcppファイルがあります
/* This is a trivial JNI example where we use a native method
* to return a new VM String. See the corresponding Java source
* file located at:
*
* apps/samples/hello-jni/project/src/com/example/hellojni/HelloJni.java
*/
JNIEXPORT jstring JNICALL
Java_com_some_player_MainActivity_stringFromJNI( JNIEnv* env,
jobject thiz )
{
return env->NewStringUTF("Hello from JNI!");
}
それを呼び出すJavaクラス
package com.some.player;
public class MainActivity extends Activity {
public native String stringFromJNI();
static {
System.loadLibrary("hello-jni");
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = (TextView) findViewById(R.id.textView);
tv.setText(stringFromJNI());
}
}
makeファイル
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.cpp
include $(BUILD_SHARED_LIBRARY)
問題は、ネイティブ関数を呼び出すと、
07-28 23:42:34.256: E/AndroidRuntime(32398): java.lang.UnsatisfiedLinkError: stringFromJNI