If I have my Android NDK project use a .c file instead of .cpp I cannot resolve any functions inside JNIEnv*. Here is how I'm trying to use it:
(*env)->GetCharArrayElements(chrs, 0);
I have also tried:
GetCharArrayElements(env, chrs, 0);
env->GetCharArrayElements(chrs, 0);
This is getting frustrating as I have some c library projects that I would like to include but if I have .cpp file then the library will need to be ported somehow and I would like to avoid that. Any help/ideas would be great.
Here is my Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := NDKDemo
LOCAL_SRC_FILES := NDKDemo.c
include $(BUILD_SHARED_LIBRARY)
edit:
Here is how I'm declaring JNIEnv*
#include <jni.h>
JNIEXPORT void JNICALL Java_com_atd_ndkdemo_NDKDemo_charManip(JNIEnv* env, jobject obj, jcharArray chrs)
jchar* cchar0 = GetCharArrayElements(chrs, 0);
jchar* cchar1 = (*env)->GetCharArrayElements(env, chrs, 0);
jchar* cchar2 = (*env)->GetCharArrayElements(chrs, 0);
jchar* cchar3 = env->GetCharArrayElements(chrs, 0);
}
Interestingly, cchar0 doesn't complain until I try to compile, then eclipse tells me it cannot be resolved again.