I am trying to do an abi split in my gradle with the following code
splits {
abi {
enable true
reset()
include 'x86', 'armeabi-v7a'/*, 'arm64-v8a', 'x86_64'*/
universalApk true
}
}
def abiVersionCodes = ['armeabi-v7a': 1, 'x86': 2, /*'arm64-v8a': 2,'x86_64': 4*/]
android.applicationVariants.all { variant ->
// assign different version code for each output
variant.outputs.each { output ->
def filter = output.getFilter(OutputFile.ABI)
if (filter != null) {
output.versionCodeOverride = abiVersionCodes.get(output.getFilter(OutputFile.ABI)) * 1000000 + android.defaultConfig.versionCode
}
}
}
It is producing outputs named correctly, and when I use the apk analyzer, under the lib directory, the armeabi-v7a apk will only contain an so under the lib/armeabi-v7a directory, and likewise for the x86 apk. However, the armeabi-v7a also contains a armeabi and x86 folder with only a META-INF folder containing only a MANIFEST.MF file, no so.
When uploading these multiple apks to the dev console, each split apk has listed under
Differentiating apk details: Native platforms none (+ 3 common)
and universal apk has
Native platforms arm64-v8a, x86_64 (+ 3 common) The error on the console for the arm and universal apk is
"Fully shadowed APK PROBLEM This APK will not be served to any users because it is completely shadowed by one or more APKs with higher version codes. RESOLUTION Remove this APK from your release or review the targeting and version codes of the APKs that you are including in this release. "
When I add under packaging options
packagingOptions {
exclude '**/x86/**'
}
then the resulting apks, split and universal, will not have x86 supported. However, I don't see a way to specify packagingOptions for each application variant, so this is not a workable solution, and it is clearly not the correct way to do things even if it were. The problem seems to be that the apk is considered to support x86 just because it has a x86 directory, even if it is mostly empty, and that is causing both split apks to advertise that they support the exact same architectures, when they do not.
Curiously, the universal apk says it supports arm64-v8a, armeabi, armeabi-v7a, x86, x86_64 , which is NOT what I'd expect after calling reset() and include 'x86', 'armeabi-v7a' in the abi block. To prevent 64 bit archs from being included I have to add in defaultConfig
ndk {
abiFilters "armeabi-v7a", "x86"
}
but it still includes an empty armeabi folder.
What is the correct way to split abi so that the dev console sees only what the apk actually supports? Is removing the empty directories the correct approach? Is there a reason the empty directory is being created that i can trace?