I currently build two separate APK files, one for API levels 16-20 and another for API level 21+.
For API 16-20 I use 'com.squareup.okhttp3:okhttp:3.12.0', which is the last version supported on API 20 and lower. For API 21+ I use the latest version.
I am implementing this using build flavors, see below:
productFlavors {
...
api21plus
{
dimension "apiLevel"
minSdkVersion 21
versionCode = 514
versionName = '1.514'
}
api16to20
{
dimension "apiLevel"
minSdkVersion 16
maxSdkVersion 20
versionCode = 513
versionName = '1.513'
}
}
...
dependencies {
api21plusImplementation 'com.squareup.okhttp3:okhttp:4.9.1'
api16to20Implementation 'com.squareup.okhttp3:okhttp:3.12.0'
}
I would like to migrate to the Android App Bundle format, but I am not sure how to achieve the same result. Is there some way to specify different dependencies for different ABI splits\ API levels?
You can upload two App Bundles targeting different Android versions, similarly to how you upload two different APKs targeting Android versions.
This is the only way as the AAB doesn't support code targeting by Android SDK version.