以前我有两个Android Studio项目。一个是使用放在/src/main/jniLibs
中的一些共享库(让我们称之为项目bmf)。第二个项目是我的实际库,它使用其他项目(bmf)作为.aar。
如果某个应用程序现在正在使用该库,我必须使用共享库(bmf)添加项目,因为.so文件未打包。因为我想将两个项目合并到一个库项目中,所以我将bmf项目作为模块导入。现在,如果我组装库,则不包括模块的.so文件。我该如何解决这个问题?
我的app-module构建脚本如下所示:
apply plugin: 'com.android.library'
android {
compileSdkVersion 15
buildToolsVersion "26.0.2"
lintOptions {
abortOnError false
}
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.0'
implementation project(':pbJavaBmf')
}
我的bmf-module构建脚本如下所示:
apply plugin: 'com.android.library'
android {
compileSdkVersion 15
buildToolsVersion "26.0.2"
lintOptions {
abortOnError false
}
defaultConfig {
minSdkVersion 15
targetSdkVersion 15
}
externalNativeBuild {
ndkBuild {
path "src/main/jni/Android.mk"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
task buildNative(type: Exec, description: 'Pack .so with module') {
def ndkDir = android.ndkDirectory
commandLine "$ndkDir/ndk-build.cmd",
'-C', file('src/main/jni').absolutePath, // Change src/main/jni the relative path to your jni source
'-j', Runtime.runtime.availableProcessors(),
'V=1',
'NDK_DEBUG=1',
'NDK_LIBS_OUT=../jniLibs'
}
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:support-v4:18.0.0'
}