应用场景
1、react native框架没有armeabi的so库文件,而我们又需要打包armeabi架构的apk。
实现方法
在build.gradle文件中加入以下代码,实现打包apk动态替换so库文件
project.afterEvaluate {
//动态替换so库文件,在执行packageRelease任务之前将armeabi-v7a目录下的所有so文件拷贝到armeabi目录
packageRelease.doFirst {
delete{
delete 'build/intermediates/transforms/stripDebugSymbol/release/0/lib/armeabi'
}
copy{
from 'build/intermediates/transforms/stripDebugSymbol/release/0/lib/armeabi-v7a'
into 'build/intermediates/transforms/stripDebugSymbol/release/0/lib/armeabi'
include '*.so'
}
delete{
delete 'build/intermediates/transforms/mergeJniLibs/release/0/lib/armeabi'
}
copy{
from 'build/intermediates/transforms/mergeJniLibs/release/0/lib/armeabi-v7a'
into 'build/intermediates/transforms/mergeJniLibs/release/0/lib/armeabi'
include '*.so'
}
}
}