问题描述
我要建立的4种不同的Android CPU处理器架构采用摇篮4个单独的APK(armeabi armeabi-V7A 86 MIPS)。
I want to build 4 separate apks for 4 different Android CPU processor architectures (armeabi armeabi-v7a x86 mips) using Gradle.
我已经原生的OpenCV库建为4个CPU架构在库的文件夹。
I have native OpenCV libraries built for 4 CPU architectures in the libs folder.
libs
-armeabi
-armeabi-v7a
-x86
-mips
欲每个的apk只包含相应于正确的CPU架构OpenCV库。
I want to each apk only contains the OpenCV library corresponding to the correct CPU architecture.
目前构建脚本如下:
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
compile project(':workspace:OpenCV4Android:sdk:java')
}
android {
compileSdkVersion 11
buildToolsVersion "18.1.0"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
flavorGroups "abi", "version"
productFlavors {
x86 {
flavorGroup "abi"
}
arm {
flavorGroup "abi"
}
mips {
flavorGroup "abi"
}
}
}
}
有人可以帮助我解决这个好吗?
Can someone help me to resolve this please?
干杯,
推荐答案
由于Android的摇篮插件版本13,你现在就可以生成单独的APK的使用新的分裂的机制。你可以读到它here.
As of Android Gradle Plugin version 13 you can now generate seperate APK's using the new "split" mechanism. You can read about it here.
默认的文件结构,把你的.so文件是:
The default file structure for placing your .so files is:
src
-main
-jniLibs
-armeabi
-arm.so
-armeabi-v7a
-armv7.so
-x86
-x86.so
-mips
-mips.so
请注意,该.so文件的名称是不重要,只要它具有的.so扩展
Note that the name of the .so file is unimportant as long as it has the .so extension.
然后在你的摇篮构建文件:
Then in your Gradle build file:
android {
...
splits {
abi {
enable true
reset()
include 'x86', 'armeabi-v7a', 'mips', 'armeabi'
universalApk false
}
}
}
和
// map for the version code
ext.versionCodes = ['armeabi-v7a':1, mips:2, x86:3]
import com.android.build.OutputFile
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
output.versionCodeOverride =
project.ext.versionCodes.get(output.getFilter(OutputFile.ABI)) * 1000000 + android.defaultConfig.versionCode
}
}
请注意,该版本codeS上面ext.version codeS在很大程度上是不相关的,这是此处添加了独特的偏移每个ABI的类型,这样的版本codeS并不冲突。
Note that the version codes above in ext.versionCodes are largely irrelevant, this is here to add a unique offset for each ABI type so version codes do not clash.
这篇关于摇篮的Android版本为不同的处理器架构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!