男人......这个错误让我失望。
logcat的:
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): FATAL EXCEPTION: main
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): java.lang.IllegalStateException: Could not execute method of the activity
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at android.view.View$1.onClick(View.java:2072)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at android.view.View.performClick(View.java:2408)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at android.widget.CompoundButton.performClick(CompoundButton.java:99)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at android.view.View$PerformClick.run(View.java:8819)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at android.os.Handler.handleCallback(Handler.java:587)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at android.os.Handler.dispatchMessage(Handler.java:92)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at android.os.Looper.loop(Looper.java:123)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at java.lang.reflect.Method.invokeNative(Native Method)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at java.lang.reflect.Method.invoke(Method.java:521)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at dalvik.system.NativeStart.main(Native Method)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): Caused by: java.lang.reflect.InvocationTargetException
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at com.example.viewer.Viewer.denoiseSlice(Viewer.java:170)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at java.lang.reflect.Method.invokeNative(Native Method)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at java.lang.reflect.Method.invoke(Method.java:521)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at android.view.View$1.onClick(View.java:2067)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): ... 12 more
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): Caused by: java.lang.UnsatisfiedLinkError: RicianDenoise
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): at com.example.viewer.Viewer.RicianDenoise(Native Method)
01-29 22:25:00.293: ERROR/AndroidRuntime(27386): ... 16 more
加载库并声明它:
public native void RicianDenoise(int w, int h, int p,
short [] s_noised_slice, double [] d_noised_slice,
short [] s_denoised_slice, double [] d_denoised_slice);
static {
System.loadLibrary("denoise");
}
C函数:
void
Java_com_example_viewer_Viewer_RicianDenoise (JNIEnv *env, jclass cls, jint M,
jint N, jint P, jshort * s_noised_slice,
jdouble * d_noised_slice,
jshort * s_denoised_slice,
jdouble * d_denoised_slice) {
/* ... */
}
我跑了
ndk-build -B -C [project] / jni
我无法得到任何工作。对此问题有任何建议或经验吗? logcat中的调用行是我只是试图调用函数,顺便说一句。谢谢......请成为我的英雄:(
答案 0 :(得分:1)
java中的数组不能转换为C / C ++中的数组类型指针,在JNI中
在本机端使用此方案来声明您的阵列:
for double []使用jdoubleArray
简而言之[]使用jshortArray
答案 1 :(得分:0)
您的库是否使用其他C / C ++库,是否可以使用系统路径访问?