How to split apk in android studio

How to split apk in android studio

Go to build.gradle(app) and paste the highlighted code . that’s all.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "your Application ID"
        minSdkVersion 21
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }


    splits {
        abi {
            enable true
            reset()
            include "x86_64","x86","armeabi","armeabi-v7a","arm64-v8a","mips"
            universalApk false

        }
    }


    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    lintOptions {

        checkReleaseBuilds false

    }
}

ext.densityCodes = ['armeabi':1, 'armeabi-v7a':2, 'arm64-v8a':3,'mips':4,'x86':5,'x86_64':6]
import com.android.build.OutputFile


android.applicationVariants.all { variant ->

    variant.outputs.each { output ->

        def baseDensityVersionCode =

                project.ext.densityCodes.get(output.getFilter(OutputFile.DENSITY))

        if (baseDensityVersionCode != null) {
            output.versionCodeOverride =
                    baseDensityVersionCode * 1000 + variant.versionCode
        }
    }
}


dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    compile 'com.github.barteksc:android-pdf-viewer:2.8.2'
    implementation 'com.android.support:recyclerview-v7:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'
    compile 'com.android.support:recyclerview-v7:27.1.1'
    compile 'com.android.support:cardview-v7:27.1.1'

}

Leave a Reply

Your email address will not be published. Required fields are marked *