修改前CMakeLists.txt动态库配置部分
add_library( avcodec-57 SHARED IMPORTED ) set_target_properties( avcodec-57 PROPERTIES IMPORTED_LOCATION libs/armeabi/libavcodec-57.so )执行后出错
Error while executing 'D:\Android\Sdk\cmake\3.6.3155560\bin\cmake.exe' with arguments {--build E:\MyApplication2\app\.externalNativeBuild\cmake\debug\armeabi --target native-lib} ninja: error: 'libs/armeabi/libavcodec-57.so', needed by '../../../../build/intermediates/cmake/debug/obj/armeabi/libnative-lib.so', missing and no known rule to make it在提示信息可以看出编译时的路径为
E:\MyApplication2\app\.externalNativeBuild\cmake\debug\armeabi因此在CMakeList.txt中增加一个配置,即CMakeList.txt所在的目录
set(CURRENT_DIR ${CMAKE_SOURCE_DIR}) //在Gradle Console输出信息 //CMAKE_SOURCE_DIR: E:/MyApplication2/app message("CURRENT_DIR:" ${CMAKE_SOURCE_DIR}) add_library( avcodec-57 SHARED IMPORTED ) set_target_properties( avcodec-57 PROPERTIES IMPORTED_LOCATION ${CURRENT_DIR}/libs/armeabi/libavcodec-57.so )