ar first I am sorry for spelling these words in english cause my ubuntu is without Chinese... 1,,....I register like this way in com_android_server_CanService.cppstatic const JNINativeMethod methods[] = { {"read_data", "()Ljava/lang/String;String jstring", (void *)read_flexcan}, {"flexcan_open", "()Z", (void *)flexcan_open} }; 2...in my CanService.java I wrote these code: private static native boolean flexcan_open(); private static native String read_data(); of course both of them are in public class CanService extends ICanService.stub 3....the follow ocde are in my ICanService.aidl at android/ospackage android.os;interface ICanService{ boolean flexcan_open(); String read_data();}is something wrong???? Maybe I should delete the static at register java methods struct ...???? thanks a lot..(to be honest there are many ugly spelling and wrong use of English rule.I hope you understand me...)
and I just check your code .your code is static const JNINativeMethod method_table[] = { {"init_native", "()Z", (void*)ttt_init}, {"setVal_native", "(I)V", (void*)ttt_setVal}, {"getVal_native", "()I", (void*)ttt_getVal}, };alright ,it's none of static's business..... I was wrong...
OK thanks so much .I correct my error by myself.....so that is where I did wrong..... at first I declared the function proto at ICanService.aidl whit the same name in JNINativeMethod struct ...you know they are native and static....and I did this: change the content in ICanService.aidl..Make sure the function proto in ICanService.aidl are implemented in CanService.java not the function proto which is declared in JNINativeMethod struct..
com_android_server_ CanService.cpp 定义的JNI方法不匹配导致的。同时,请确保
frameworks/base/services/java/com/android/server路径下存在 CanService.java 文件
frameworks/base/services/jni 路径下存在 com_android_server_ CanService.cpp 文件
注意你这两个文件的名称一定要匹配,不匹配的话就会出问题。
1,,....I register like this way in com_android_server_CanService.cppstatic const JNINativeMethod methods[] =
{
{"read_data", "()Ljava/lang/String;String jstring", (void *)read_flexcan},
{"flexcan_open", "()Z", (void *)flexcan_open}
};
2...in my CanService.java I wrote these code:
private static native boolean flexcan_open();
private static native String read_data();
of course both of them are in public class CanService extends ICanService.stub
3....the follow ocde are in my ICanService.aidl at android/ospackage android.os;interface ICanService{ boolean flexcan_open();
String read_data();}is something wrong???? Maybe I should delete the static at register java methods struct ...????
thanks a lot..(to be honest there are many ugly spelling and wrong use of English rule.I hope you understand me...)
static const JNINativeMethod method_table[] = {
{"init_native", "()Z", (void*)ttt_init},
{"setVal_native", "(I)V", (void*)ttt_setVal},
{"getVal_native", "()I", (void*)ttt_getVal},
};alright ,it's none of static's business..... I was wrong...
at first I declared the function proto at ICanService.aidl whit the same name in JNINativeMethod struct ...you know they are native and static....and I did this:
change the content in ICanService.aidl..Make sure the function proto in ICanService.aidl are implemented in CanService.java not the function proto which is declared in JNINativeMethod struct..