Skip to content

How to Fix Android APK Split Errors — Multi-APK Builds

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about How to Fix Android APK Split Errors. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

APK splits are not generating separate APKs:

Error: All flavors have the same version code 1.

or:

APK splits configured but only one APK is generated.

Quick Fix

Step 1: Enable ABI splits correctly

WRONG — missing reset:

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

RIGHT — complete configuration:

android {
    splits {
        abi {
            enable true
            reset()
            include "armeabi-v7a", "arm64-v8a", "x86_64"
            universalApk true
        }
    }
}

// Map ABI to version code
ext.abiCodes = ['armeabi-v7a': 1, 'arm64-v8a': 2, 'x86_64': 3]
import com.android.build.OutputFile

android.applicationVariants.all { variant ->
    variant.outputs.each { output ->
        def abi = output.getFilter(OutputFile.ABI)
        if (abi != null) {
            output.versionCodeOverride = abiCodes[abi] * 1000 + variant.versionCode
        }
    }
}

Step 2: Fix density splits

splits {
    density {
        enable true
        reset()
        include "mdpi", "hdpi", "xhdpi", "xxhdpi", "xxxhdpi"
        compatibleScreens "small", "normal", "large", "xlarge"
    }
}

Step 3: Generate universal APK

splits {
    abi {
        universalApk true  // generates both split and universal APKs
    }
}

Step 4: Check the output directory

ls app/build/outputs/apk/

Each split should have its own subdirectory.

Prevention

  • Assign unique version codes to each split using versionCodeOverride.
  • Test each split APK on the appropriate device.
  • Use Android App Bundles (AAB) instead of APK splits for Play Store distribution.

Common Mistakes with apk split

  1. Using head and tail instead of pattern matching, causing runtime errors on empty lists
  2. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks
  3. Using return to exit a function early instead of wrapping a pure value in the monad

These mistakes appear frequently in real-world Android code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What is the difference between ABI and density splits?

ABI splits separate APKs by CPU architecture (ARM, x86). Density splits separate by screen density (hdpi, xhdpi). Both reduce APK size by only including relevant resources.

Should I use APK splits or Android App Bundles?

App Bundles (AAB) are the preferred format for Play Store. They offload APK generation and signing to Google Play and support on-demand delivery.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro