gpt4 book ai didi

android - 如何使用 2 个字符串参数从 jni java 库调用?

转载 作者:行者123 更新时间:2023-11-28 05:19:12 25 4
gpt4 key购买 nike

我试过这样的:

 void CallbackStringFromJni(const char *name, const char *type)
{
jboolean isAttached;
JNIEnv *env;
jmethodID mid;
jstring js, js2;
LOGE("callbackStringFromJni Begin");
env = getJniEnv(&isAttached);
if (env == NULL)
goto FAIL0;

mid = getApplicationJniMethodId(env, applicationJniObj, "callbackStringFromJni", "(SS)V");
if (mid == NULL)
goto FAIL1;

js = (*env)->NewStringUTF(env, name);
js2 = (*env)->NewStringUTF(env, type);
(*env)->CallVoidMethod(env, applicationJniObj, mid, js, js2);

if (isAttached)
{
(*global_vm)->DetachCurrentThread(global_vm);
}
LOGE("callbackStringFromJni End");
return;
FAIL1:
if (isAttached)
{
(*global_vm)->DetachCurrentThread(global_vm);
}
FAIL0:
LOGE("callbackStringFromJni FAILED");
return;
}

但是我得到了这个:

01-26 11:53:02.500: E/VidyoMobile app/src/main/jni/ndkVidyoSample.c(31091): getApplicationJniMethodId - getApplicationJniMethodId: Failed to get callbackStringFromJni method
01-26 11:53:02.603: E/AndroidRuntime(31091): java.lang.NoSuchMethodError: no non-static method "Lcom/vidyo/vidyocore/VidyoCoreApplication;.callbackStringFromJni(SS)V"

我在 java 中的方法如下所示:

public void callbackStringFromJni(String name, String typeS) {
Log.e("","callbackStringFromJni name: " + name + ".. type: " + typeS);
}

最佳答案

它必须是这样的:

mid = getApplicationJniMethodId(env, applicationJniObj, "callbackStringFromJni", "(Ljava/lang/String;Ljava/lang/String;)V");

不是

"(SS)V"

关于android - 如何使用 2 个字符串参数从 jni java 库调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41871959/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com