Posts

Showing posts with the label Googletest

Android NDK With Google Test

Answer : If you choose cmake to drive your externalNativeBuild (and this is the preferred option, according to Android Developers NDK guide), then you can simply add the following lines to your CMakeLists.txt : set(GOOGLETEST_ROOT ${ANDROID_NDK}/sources/third_party/googletest/googletest) add_library(gtest STATIC ${GOOGLETEST_ROOT}/src/gtest_main.cc ${GOOGLETEST_ROOT}/src/gtest-all.cc) target_include_directories(gtest PRIVATE ${GOOGLETEST_ROOT}) target_include_directories(gtest PUBLIC ${GOOGLETEST_ROOT}/include) add_executable(footest src/main/jni/foo_unittest.cc) target_link_libraries(footest gtest) If your build succeeds, you will find app/.externalNativeBuild/cmake/debug/x86/footest . From here, you can follow the instructions in README.NDK to run it on emulator or device. Notes : make sure that the ABI matches the target you use (the guide is not very clear about this). the list of ABI's that are built is controlled by abiFilters in build.gradle . In Android ...