Google includes support for google test inside of the Android NDK (see https://android.googlesource.com/platform/ndk.git/+/master/sources/third_party/googletest/README.NDK). This works surprisingly well. You can actually create and run native C++ executables on an Android device this way.
The problem is that there appears to be no way to exercise JNI code. The Android NDK disallows these highly useful functions:
/*
* VM initialization functions.
*
* Note these are the only symbols exported for JNI by the VM.
*/
#if 0 /* In practice, these are not exported by the NDK so don't declare them */
jint JNI_GetDefaultJavaVMInitArgs(void*);
jint JNI_CreateJavaVM(JavaVM**, JNIEnv**, void*);
jint JNI_GetCreatedJavaVMs(JavaVM**, jsize, jsize*);
#endif
The only other way I see in jni.h to get a JavaVM is through JNI_OnLoad
, but that only gets called for shared libraries that are loaded from Java.
Is there any way around this?
In my case I don't want to call my Google Tests through the Android test framework. I want to use Google Test as the driver for all of my cross-platform unit tests.
See similar: Unit testing on Android NDK