Android Studio创建Include c++项目,并在c++代码引用本地so

 
  
 
  
so放在lib下,头文件放在src/main/cpp/include下
修改build.gradle
在defaultConfig添加

ndk {
    abiFilters "armeabi", "armeabi-v7a"
}
在android添加
 
  
sourceSets.main {
    jniLibs.srcDirs = ['libs']
    jni.srcDirs = []
}

 
  
 
  
add_library( ffmpeg
             SHARED
             IMPORTED)
set_target_properties( ffmpeg
                       PROPERTIES IMPORTED_LOCATION
                       ../../../../libs/armeabi-v7a/libffmpeg.so )

include_directories(src/main/cpp/include)

target_link_libraries( native-lib ffmpeg
                       ${log-lib} )
 
  
 
 

你可能感兴趣的:(Android Studio创建Include c++项目,并在c++代码引用本地so)