博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android aar 包含静态库的打包
阅读量:4030 次
发布时间:2019-05-24

本文共 958 字,大约阅读时间需要 3 分钟。

前言

一般我们开发的android sdk(arr)使用了jni后,aar中只会包含动态库的(so文件),所以以前一直没有注意与处理过android平台上的静态库的打包。今天尝试了一下,有遇到了一直打不出.a文件和aar构建出来后没有.a文件的问题,后来通过搜索找到了不明原因的解决方案。后续需要弄清楚原因和撑握相关的知识点。

方案

1、CMakeLists.txt文件,把库的打包类型改为STATIC

2、需要在build.gradle 文件的nativeBundleExport配置上加上bundleStatic
3、需要在build.gradle 文件的externalNativeBuild配置上加上targets

//CMakeLists.txt文件add_library( # Sets the name of the library.             库名             # Sets the library as a shared library.             STATIC             # Provides a relative path to your source file(s).             src/main/jni/xxx.cp)// build.gradle文件 nativeBundleExport {        bundleStatic = true //加上了可以在aar才加包含打出来的.a文件    }  externalNativeBuild {            cmake {                arguments '-DANDROID_TOOLCHAIN=clang', "-DANDROID_STL=c++_static"                cppFlags "-std=c++11 -frtti -fexceptions"                abiFilters 'arm64-v8a','armeabi-v7a','x86','x86_64'                targets '库名' //加上了可以编译出.a文件            }

参考文档

转载地址:http://pkmbi.baihongyu.com/

你可能感兴趣的文章
[LeetCode By Python]167. Two Sum II - Input array is sorted
查看>>
[LeetCode BY Python]169. Majority Element
查看>>
[LeetCode By Python]172. Factorial Trailing Zeroes
查看>>
[LeetCode By MYSQL] Combine Two Tables
查看>>
python jieba分词模块的基本用法
查看>>
[CCF BY C++]2017.12 最小差值
查看>>
[CCF BY C++]2017-12 游戏
查看>>
如何打开ipynb文件
查看>>
[Leetcode BY python ]190. Reverse Bits
查看>>
面试---刷牛客算法题
查看>>
Android下调用收发短信邮件等(转载)
查看>>
Android中电池信息(Battery information)的取得
查看>>
SVN客户端命令详解
查看>>
Android/Linux 内存监视
查看>>
Linux系统信息查看
查看>>
用find命令查找最近修改过的文件
查看>>
Android2.1消息应用(Messaging)源码学习笔记
查看>>
在android上运行native可执行程序
查看>>
Phone双模修改涉及文件列表
查看>>
android UI小知识点
查看>>