How do I exclude ABI from Android App Bundle? - android

I know that there was an option to exclude ABIs when generating splits in Gradle which looked like this:
android {
splits {
// Configures multiple APKs based on ABI.
abi {
// Enables building multiple APKs per ABI.
enable true
// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86 and x86_64.
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
include "x86", "x86_64"
}
}
}
And here is the official reference to splits configuration
Now it is recommended to use App Bundles when publishing your App to Play Store and I don't see any option to exclude ABIs from this bundle either by using Gradle or Play Store publishing console.
The only clue I found so far is that you can enable/disable a particular split variant. For example here is how to disable ABI bundle splitting completely according to documentation:
android {
// When building Android App Bundles, the splits block is ignored.
splits {...}
// Instead, use the bundle block to control which types of configuration APKs
// you want your app bundle to support.
bundle {
abi {
// This property is set to true by default.
enableSplit = true
}
}
}
But there no mention on how to disable/enable a specific ABI set.
I already have abiFilters specified to exclude not supported NDKs, but it looks like it has no influence on App Bundle.
Update: I assumed that abiFilters are specifying ABIs to exclude from the App Bundle but it was exactly opposite and their porpose is to list ABIs to be included. After this clarification, everything seems to be working correctly.

abiFilters is the way to go. Specify the list of ABIs you want to include, and the other ones will be excluded.
You don't need the "splits" block for Android App Bundles: it's ignored.
If this doesn't work for you, then could you please provide the Gradle config with the abiFilters set, and say how you determine the ABIs present in the App Bundle?

Related

How Can i get rid of this large lib files

Please anyone help me in my project this files got entered with large size so how to get rid of this. and in other project this file aren't their
Those are libs for specific architectures. If you deliver your app using app bundle it shouldn't be a problem since app bundle will only deliver the necessary for each architecture (so the build will use less disk space).
But if want you want is offer your app to a limited abi list you can use this in your build.gradle
android {
defaultConfig {
ndk {
abiFilters 'arm64-v8a', 'x86_64'
}
}
}
check this for more abi info https://developer.android.com/ndk/guides/abis

How to restrict android app to 64 bit platform download on google play

I have an app that works only in 64 bit configuration.
I've put in the following in the abi filters
splits{
abi {
enable true
reset()
include "x86_64", "arm64-v8a"
universalApk true
}
}
But when I uploaded the app for alpha track I saw this :
How do I make sure my app is not available for download for something other than 64 bit device?
Have you tried to exclude these builds?
"exclude
Specifies a comma-separated list of ABIs that Gradle should not generate separate APKs for. Use exclude if you want to generate APKs for most ABIs, but need to exclude a few ABIs that your app doesn't support."
https://developer.android.com/studio/build/configure-apk-splits
Set universalApk false, it will build one APK for each platform;then just upload the arm64-v8a package (x86_64 is irrelevant).

Reducing the APK size - Building so files for only certain platforms

I am trying to reduce my Android app. It has a differenct packages, a client package which depenend of bunch of other packages. I am analyzing the APK and saw there are so files for different paltforms namely x86 and armeabi-v7a. I dont want x86 currently. I am using splits to restrict the so files for x86 platform with following code in my build.gradle file.
splits {
abi {
enable false
// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86 and x86_64.
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
include "armeabi-v7a"
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
universalApk false
}
}
But still I could see the x86 files. Can someone help me in what I am doing wrong?
Use abiFilters from NdkOptions to include the native libraries only of certain ABIs.
Example:
android {
// Similar to other properties in the defaultConfig block, you can override
// these properties for each product flavor in your build configuration.
defaultConfig {
ndk {
// Tells Gradle to build outputs for the following ABIs and package
// them into your APK.
abiFilters 'armeabi', 'armeabi-v7a', 'arm64-v8a'
}
}
}

How to install a specific APK on my device

I do not use Android Studio but I do everything from the command line. I am building different APKs for different architectures so my build.gradle looks like this:
...
splits {
// Configures multiple APKs based on ABI.
abi {
// Enables building multiple APKs per ABI.
enable true
// By default all ABIs are included, so use reset() and include to specify that we only
// want APKs for x86, armeabi-v7a, and mips.
// Resets the list of ABIs that Gradle should create APKs for to none.
reset()
// Specifies a list of ABIs that Gradle should create APKs for.
include "armeabi", "armeabi-v7a", "arm64-v8a"
// Specifies that we do not want to also generate a universal APK that includes all ABIs.
universalApk false
}
}
I then use the method described here to assign different version codes to the individual APKs.
This all works fine except that when I say
./gradlew tasks
there is only one task named installRelease. Running this task will then automatically choose an appropriate APK and install it.
However, I'd like to test the individual APKs separately, i.e. on my 64-bit Android device I'd first like to test armeabi, then armeabi-v7a, and finally arm64-v8a. When running installRelease, however, gradle will always automatically install arm64-v8a. So how can I force gradle to install a specific architecture?
Previously, I was using this code in build.gradle instead of the splits code shown above:
productFlavors {
arm7 {
// in the future, ndk.abiFilter might also work
ndk {
abiFilter 'armeabi-v7a'
}
}
arm8 {
ndk {
abiFilters 'arm64-v8a'
}
}
arm {
ndk {
abiFilter 'armeabi'
}
}
}
When using this code, gradle offered individual tasks named installArmRelease, installArm7Release, and installArm8Release which was exactly what I was looking for but I had to drop this code because I didn't find a way to use it alongside the code that generates different version codes for the individual APKs as described here.

How to remove extra native dependencies from app?

I am using arcgis in my app and it bundles native dependencies that are large in size. I don't want to include the x86 dependency if it means reducing the size of the apk. How do I tell gradle to automatically exclude the x86 native library.
I tried removing it manually during the build. but it shows up again after rebuild.
how do I tell gradle to automatically exclude the x86 native library
Use splits:
android {
// other good stuff here
splits {
abi {
enable true
reset()
include 'armeabi-v7a'
universalApk false
}
}
}
This tells Android to build only an ARMv7 version of your APK. You would need to adjust the include line to list what APKs you want.
However, you may be better served using splits to just build a separate x86 APK file (have include 'x86', 'armeabi-v7a') and ship both, so you better support x86 but still have smaller files.

Categories

Resources