Generating Multiple Apk according to the Native ABI
Asked Answered
H

2

1

I am building release apk based on the ABI because of apk size to publish on Play store.

So I started apk building for ABI = armeabi-v7a then building ABI = x86 and ABI = areambi

so my gradle look like this

app gradle

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.1"
    defaultConfig {
        applicationId "com.package"
        minSdkVersion 18
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        ndk {
            abiFilters "armeabi-v7a"
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        ndkBuild {
            path 'src/main/jni/Android.mk'
        }
    }
    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-v7a"

            // Specifies that we do not want to also generate a universal APK that includes all ABIs.
            universalApk false
        }
    }
}

I got this

So my question

  1. I need to make changes in versionCode 1 for each ABI, so which version code for which ABI should I use.
Howdah answered 15/11, 2017 at 7:55 Comment(0)
H
1

I have to make 2 different build

Build 1: for armeabi-v7a

versionCode 21614001
splits {
    abi {
        enable true
        reset()
        include "armeabi-v7a"
        universalApk false
    }
}

Build 2 : for x86

versionCode 61614001
splits {
    abi {
        enable true
        reset()
        include "x86"
        universalApk false
    }
}

Added native library accordingly to the abi supported.

After that published the apk Build 1 and Build 2 together will show you the supported devices.

Howdah answered 24/11, 2017 at 12:30 Comment(0)
U
2
productFlavors{  

    arm{  
        ndk{  
            abiFilters "arm64-v8a" , "armeabi"  , "armeabi-v7a"  
        }  
    }  
    x86{  
        ndk{  
            abiFilters "x86" , "x86_64"  
        }  
    }  
}  
Underskirt answered 15/11, 2017 at 8:9 Comment(1)
I need to Publish multiple apk with same package name which will going to support different abi.Howdah
H
1

I have to make 2 different build

Build 1: for armeabi-v7a

versionCode 21614001
splits {
    abi {
        enable true
        reset()
        include "armeabi-v7a"
        universalApk false
    }
}

Build 2 : for x86

versionCode 61614001
splits {
    abi {
        enable true
        reset()
        include "x86"
        universalApk false
    }
}

Added native library accordingly to the abi supported.

After that published the apk Build 1 and Build 2 together will show you the supported devices.

Howdah answered 24/11, 2017 at 12:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.