Import googletest into gradle project in Android Studio

I was hoping someone could help me figure out how to configure googletest to work from Android Studio. I want to run my unit tests in C ++ from the same IDE when I write them. I know that googletest already comes with ndk, I just can not integrate it into my project.

I found a couple of blogs and stackoverflow sections, and even googletest documentation points to the following solution (Android.mk):

   TARGET_ARCH_ABI := armeabi-v7a
   LOCAL_PATH := $(call my-dir)

   include $(CLEAR_VARS)
   LOCAL_MODULE := foo
   FILE_LIST := $(wildcard $(LOCAL_PATH)/*.cpp)
   LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
   include $(BUILD_SHARED_LIBRARY)

   include $(CLEAR_VARS)
   LOCAL_MODULE := foo_unittest
   FILE_LIST := $(wildcard $(LOCAL_PATH)/gtest/*.cpp)
   LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
   LOCAL_SHARED_LIBRARIES := foo
   LOCAL_STATIC_LIBRARIES := googletest_main
   include $(BUILD_EXECUTABLE)

   $(call import-module,third_party/googletest)

However, the Android.mk file is missing. As I understand it, gradle now generates Android.mk behind the scenes. All that remains for us is the build.gradle file. Importing a library that I could do, but importing a project that generates this library is not so clear to me.

- , , , , .

+4

All Articles