jquery 做网站,海阳seo排名,wordpress 大数据量查询,成都新冠病最新消息需求现在有一个第三方库libstatic_add.a和对应的头文件static.h#xff0c;要求封装一个Module#xff0c;该Module依赖这个静态库#xff0c;要求打包的Module包含该静态库。方案创建Android Studio Library Project创建Project时#xff0c;记得添加Include C Sup…需求现在有一个第三方库libstatic_add.a和对应的头文件static.h要求封装一个Module该Module依赖这个静态库要求打包的Module包含该静态库。方案创建Android Studio Library Project创建Project时记得添加Include C Support如果没有安装CMakeLLDB和NDK的话记得安装一下。项目创建好后包括以下目录和文件(部分目录或文件是后面添加的)build.gradle配置针对app模块的build.gradle进行如下配置//改为libraryapply plugin: ‘com.android.library‘//读取local.properties里的配置属性add_static_lib.dir该属性指明libstatic_add.a静态库所在目录Properties properties new Properties()properties.load(project.rootProject.file(‘local.properties‘).newDataInputStream())def add_static_lib properties.getProperty(‘add_static_lib.dir‘)android {compileSdkVersion 27defaultConfig {minSdkVersion 16targetSdkVersion 27versionCode 1versionName 1.0testInstrumentationRunner android.support.test.runner.AndroidJUnitRunner//添加下面ndk {abiFilters ‘armeabi-v7a‘// these platforms cover 99% percent of all Android devices}externalNativeBuild {cmake {//添加下面arguments ‘-DANDROID_PLATFORMandroid-14‘,‘-DANDROID_TOOLCHAINclang‘,‘-DANDROID_ARM_NEONTRUE‘,‘-DANDROID_STLgnustl_static‘,-DPATH_TO_ADD_STATIC_LIB:STRING${add_static_lib}cFlags ‘-O3‘, ‘-fsigned-char‘ // full optimization, char data type is signedcppFlags ‘-fsigned-char‘, -I${add_static_lib}}}}//添加下面sourceSets {main {jniLibs.srcDirs [‘src/main/cpp‘]}}//添加下面externalNativeBuild {cmake {path ‘src/main/cpp/CMakeLists.txt‘}}//添加下面sourceSets.main {jni.srcDirs []jniLibs.srcDir ‘src/main/libs‘}buildTypes {release {minifyEnabled falseproguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘}}}dependencies {implementation fileTree(dir: ‘libs‘, include: [‘*.jar‘])implementation ‘com.android.support:appcompat-v7:27.1.1‘implementation ‘com.android.support.constraint:constraint-layout:1.1.0‘implementation ‘com.android.support:design:27.1.1‘testImplementation ‘junit:junit:4.12‘androidTestImplementation ‘com.android.support.test:runner:1.0.2‘androidTestImplementation ‘com.android.support.test.espresso:espresso-core:3.0.2‘}local.properties配置针对app模块的local.propertise进行如下配置## This file must *NOT* be checked into Version Control Systems,# as it contains information specific to your local configuration.## Location of the SDK. This is only used by Gradle.# For customization when using a Version Control System, please read the# header note.#Wed May 16 13:05:05 CST 2018ndk.dirD\:\\NanRi\\Android\\android-ndk-r16bsdk.dirC\:\\Users\\suning\\AppData\\Local\\Android\\Sdk//添加如下指明libstatic_add.a静态库所在目录add_static_lib.dirD\:\\NanRi\\Android\\Android-Studio-Project\\ModuleProject\\app\\src\\main\\libs\\CMakeLists.txt配置针对app模块下的src\main\cpp\CMakeLists.txt配置如下cmake_minimum_required(VERSION 3.4.1)set(PATH_TO_ADD_STATIC_LIBCACHE STRING )message(${ANDROID_ABI})file(GLOB CPP_FILES *.cpp)add_library(native-libSHARED${CPP_FILES})include_directories(src/main/cpp)include_directories(${PATH_TO_ADD_STATIC_LIB})target_link_libraries(native-libandroidOpenSLES${PATH_TO_ADD_STATIC_LIB}/libstatic_add.a)导出AAR导出的AAR所在路径为“app\build\outputs\aar\app-debug.aar”可以将app-debug.aar改为app-debug.zip使用压缩工具打开可以看到如下打开jni文件夹可以看到里面包含了一个armeabi-v7a文件夹该文件夹包含了libnative-lib.so库