Skip to content Skip to sidebar Skip to footer

How To Add External Library In Android Studio With Cmake?

I am trying to link live555.so and .h files with an Android project using cMake. If i don't use absolute path i'm getting error. My cMake file: cmake_minimum_required(VERSION 3.4.1

Solution 1:

${PROJECT_SOURCE_DIR} is the directory where the main CMakeList.txt file resides. That's typically app/src/main/cpp. You can work out the correct relative path now.

This means that you can simply write

include_directories( ${PROJECT_SOURCE_DIR}/../jniLibs/live555/include )

add_library( live555 SHARED IMPORTED )

set_target_properties( live555 PROPERTIES IMPORTED_LOCATION ${PROJECT_SOURCE_DIR}/../jniLibs/live555/lib/${ANDROID_ABI}/live555.so)

Post a Comment for "How To Add External Library In Android Studio With Cmake?"