system app으로 사용하기 위해 다음과 같이 path를 변경함.
app/build.gradle
sourceSets {
main{
// let gradle pack the shared library into apk
//jniLibs.srcDirs = ['src/main/cpp/libtest']
jniLibs.srcDirs = ['src/libs']
}
}
"app/src/main/cpp/CMakeLists.txt"
cmake_minimum_required(VERSION 3.4.1)
#빌드된 library가 생성 될 경로를 지정
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/../../../libs/")
add_library(test_jni SHARED IMPORTED)
set_target_properties(
test_jni
PROPERTIES IMPORTED_LOCATION
${CMAKE_SOURCE_DIR}/../../../libs//libtest/${ANDROID_ABI}/libtest_jni.so )
#include_directories(${CMAKE_SOURCE_DIR}/libtest/include/)
include_directories(${CMAKE_SOURCE_DIR}/../../../libs/libtest/include/)
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
target_link_libraries(
native-lib
test_jni
${log-lib} )
해당 앱에서만 so file을 사용하기 위해 Android.mk를 수정, LOCAL_PREBUILT_JNI_LIBS_arm 변수 library path를 지정한다.
LOCAL_PREBUILT_JNI_LIBS_arm := app/libs/libnative-lib.so \
app/libs/libtest/armeabi-v7a/libtest_jni.so
빌드 결과 확인
./priv-app/NDKSample/lib/arm/libtest_jni.so
./priv-app/NDKSample/lib/arm/libnative-lib.so
참조:
https://stackoverflow.com/questions/3742090/custom-directory-for-cmake-library-output
'android' 카테고리의 다른 글
android ir to android keycode mapping (0) | 2018.06.21 |
---|---|
Android Custom KeyCode 추가 (0) | 2018.06.21 |
[NDK] so 포함한 apk가 so loading 실패 (2) (0) | 2018.06.19 |
[NDK] so 포함한 apk가 so loading 실패 (0) | 2018.06.18 |
android sdk build tool update 방법 (0) | 2018.06.18 |