Contact Us : +91 90331 80795

Blog Details

Breadcrub
Blog Detail

Fixing the 16 KB Memory Issue in Google Play Console

If you are getting an error like “16 KB Memory Issue” or messages such as:

Execution failed for task ':app:packageReleaseBundle'.
Error: Java heap space

or

FileSize exceeds limit — cannot allocate 16384 bytes (16 KB

This means that your build process is running out of memory.

When you build an app for release, the Android build tools (Gradle, Java, or the NDK) need enough memory to complete all packaging and compiling tasks. If your system does not have enough allocated memory, or if Gradle is not configured correctly, it can cause this “16 KB” memory issue.

This guide explains, in very simple words, how to fix it step-by-step — including which files to edit, what exact code to add, how to change the NDK version, and what commands to run.

It works for both Flutter and native Android projects.

 

Before You Start

Before you make any changes, do these basic safety steps:

 
1. Backup your project — either by making a commit in Git or by copying the folder.
 
2. Check your computer’s RAM — the more RAM you have, the more memory you can safely assign to Gradle.
 
3. Ensure Android tools are installed — make sure you have the Android SDK, Android Studio, and command-line tools installed.
 
4. For Flutter developers — confirm that Flutter SDK is properly added to your PATH.
 
Keeping a backup is very important because you will be editing project files, and one mistake can break the build setup.
 
 

Understanding the Main Causes


 
The 16 KB memory issue usually appears because:
 
  • Gradle (the build system) is not getting enough memory.

  • The Android Gradle Plugin or Gradle version is outdated.

  • The NDK version is not stable or does not match your dependencies.
  • The project has too many large files or unoptimized resources.
Now let’s go through all the steps one by one.
 
 

Step 1: Increase Gradle and JVM Memory

 
Open your project folder and find the file:
 
📁 <project-root>/gradle.properties
 
If you are using Flutter, open:
 
📁 <flutter-project>/android/gradle.properties
 
Add or update these lines:
# Increase Gradle and Java memory
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

# Optional: make Gradle faster
org.gradle.parallel=true
org.gradle.configureondemand=true

# Kotlin memory (if used)
kotlin.daemon.jvm.options=-Xmx2048m
 
Explanation
 
  • -Xmx4096m means Gradle can use up to 4 GB of memory. If your system has more than 16 GB of RAM, you can increase it to 6144m.

  • -XX:+HeapDumpOnOutOfMemoryError helps generate a file if Gradle runs out of memory, which can help debug later.

  • The parallel build option makes Gradle work on multiple modules at the same time.
Save the file after adding these lines.
 

 

Step 2: Update Gradle and Android Gradle Plugin

 
Outdated Gradle or Android Gradle Plugin (AGP) versions can cause memory errors.
 

A) Update the Gradle Wrapper

 
Open the file:
📁 <project-root>/gradle/wrapper/gradle-wrapper.properties
 
Change the distribution URL to use a newer Gradle version:
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip

 

B) Update the Android Gradle Plugin

 
Open:
📁 <project-root>/build.gradle (project-level)
 
Inside the buildscript block, find this part and update:
buildscript {
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:8.0.2'
    }
}
Make sure the Gradle version and the Android Gradle Plugin version are compatible. If Android Studio shows a prompt to upgrade, accept it.
 
 

Step 3: Change or Fix the NDK Version

 
The NDK (Native Development Kit) is used to compile native C or C++ code. Sometimes, certain versions of NDK cause memory problems during builds.
 

A) Choose a Stable Version

 
Common stable versions:
 
  • 21.4.7075529 (recommended for compatibility)

  • 23.1.7779620 (for newer builds)

 

B) Install NDK

 
Using Android Studio GUI:
 
  1. Go to Tools → SDK Manager → SDK Tools.
  2. Check “NDK (Side by side)”.
  3. Choose the version you want and click Apply.
 
Using Command Line:
sdkmanager "ndk;23.1.777962

 

C) Add to local.properties (optional)

Open <project-root>/local.properties and add:

sdk.dir=/Users/you/Library/Android/sdk
ndk.dir=/Users/you/Library/Android/sdk/ndk/23.1.7779620

(Change the path based on your OS.)

 

D) Pin NDK Version in Gradle

Open <project-root>/app/build.gradle and inside the android {} block, add:

android {
    compileSdk 35
    ndkVersion "23.1.7779620"
}

Now your project will always use this version.

 

Step 4: Optimize Packaging and Assets

 
Sometimes memory issues happen because the app has too many large files.
 
Here’s how to reduce that:
 

A) Compress Large Files

 
  • Optimize images using TinyPNG or ImageOptim.

  • Move large video or data files to the cloud and load them when the app runs.

 

B) Exclude Extra Files

In app/build.gradle, inside android {}, add:

packagingOptions {
    resources {
        excludes += ['META-INF/DEPENDENCIES', 'META-INF/LICENSE', 'META-INF/NOTICE']
    }
    jniLibs {
        useLegacyPackaging = true
    }
}

 

C) Use Only Required ABIs

defaultConfig {
    ndk {
        abiFilters 'armeabi-v7a','arm64-v8a'
    }
}

This prevents Gradle from building unnecessary native files for all architectures, which saves time and memory.

 

D) Shrink Resources (optional)

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

 

Step 5: Tune Gradle Workers

 
If your system runs out of memory even after increasing the Gradle heap size, reduce the number of workers.
 

In gradle.properties:

org.gradle.workers.max=2
Or run from the command line:
./gradlew assembleRelease --max-workers=2
This tells Gradle to build fewer tasks in parallel, using less memory.
 
 

Step 6: Clean and Rebuild

 
It’s always a good idea to clean up your project after making changes.
 
For Flutter projects:
flutter clean
flutter pub get
flutter build appbundle --release

 

For native Android:
./gradlew clean
./gradlew assembleRelease

 

If problems persist, clear the Gradle cache:

rm -rf ~/.gradle/caches/
rm -rf ~/.gradle/daemon/

Then rebuild again.

 

Step 7: Update Your CI or Build Server

 
If you are using GitHub Actions or another CI/CD tool, ensure you allocate sufficient memory.
 

Example GitHub Actions setup:

name: Android CI

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    env:
      JAVA_TOOL_OPTIONS: "-Xmx4096m -Dfile.encoding=UTF-8"
    steps:
      - uses: actions/checkout@v4
      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          distribution: 'temurin'
          java-version: '17'
      - name: Install Android SDK/NDK
        run: |
          yes | sdkmanager --licenses
          sdkmanager "platform-tools" "platforms;android-35" "build-tools;35.0.2" "ndk;23.1.7779620"
      - name: Build
        run: ./gradlew assembleRelease -Dorg.gradle.jvmargs="-Xmx4096m" --max-workers=2

This ensures your CI environment has enough memory to build the project without errors.

 

Step 8: Sparkle Web’s Proven Setup

 
At Sparkle Web, we fix this issue by using a consistent and reliable setup:
 
  • Same NDK version pinned for every developer and CI.

  • Optimized gradle.properties settings for faster builds.

  • Docker-based build machines with high memory.
  • Heap dump monitoring for advanced troubleshooting.
This keeps building stable, fast, and error-free.
 
 

Step 9: Debugging Tips

 
If the issue continues, run your build with logs enabled:
./gradlew assembleRelease --stacktrace --info

Look for lines with OutOfMemoryError and check which task failed (e.g., DEX, AAPT2, or NDK).

 
If you find a heapdump file, open it using JVisualVM or Android Studio’s built-in memory analyzer.
 
 

Step 10: Final Checklist (Copy and Paste Ready)

 
gradle.properties
org.gradle.jvmargs=-Xmx4096m -XX:MaxMetaspaceSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true
kotlin.daemon.jvm.options=-Xmx2048m
org.gradle.workers.max=2
android.enableBuildCache=true

gradle-wrapper.properties

distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-all.zip

build.gradle (project-level)

classpath 'com.android.tools.build:gradle:8.0.2'

app/build.gradle

android {
    compileSdk 35
    ndkVersion "23.1.7779620"
    defaultConfig {
        applicationId "com.example.app"
        minSdk 23
        targetSdk 35
        multiDexEnabled true
    }
    packagingOptions {
        resources {
            excludes += ['META-INF/DEPENDENCIES', 'META-INF/LICENSE', 'META-INF/NOTICE']
        }
        jniLibs {
            useLegacyPackaging = true
        }
    }
    defaultConfig {
        ndk {
            abiFilters 'armeabi-v7a', 'arm64-v8a'
        }
    }
}
dependencies {
    implementation 'androidx.multidex:multidex:2.0.1'
}

local.properties

sdk.dir=/Users/you/Library/Android/sdk
ndk.dir=/Users/you/Library/Android/sdk/ndk/23.1.7779620

 

Step 11: If the Problem Still Happens

 
If none of the above fixes help:
 
  • Try on a computer with more memory (at least 16 GB RAM).

  • Check large assets again and reduce them.

  • Try splitting the build per ABI or module.
  • If the issue still occurs, it could be a bug in the Android toolchain. You can file a report on the Android issue tracker with your logs.

 

Before Uploading to Play Console

 
Make sure:
 
1. The build completes successfully with flutter build appbundle --release or ./gradlew bundleRelease.
 
2. Test your .aab file locally using bundletool.
 
3. Verify the AAB size and check ABIs included.
 
 

Summary

 
This memory issue happens when Gradle or Java doesn’t have enough memory during the build.
By increasing memory, updating tools, and pinning NDK versions, you can solve it easily.
 
Remember:
 
  • Always use stable versions.

  • Keep your Gradle files optimized.

  • Clean and rebuild regularly.
After applying these steps, your builds should complete smoothly without memory errors, and your uploads to Google Play Console will go through successfully.
 

Conclusion

 
The 16 KB memory issue in Google Play Console can be frustrating, but with the right configuration and best practices, it’s easy to fix.
By increasing Gradle memory, updating tools, and optimizing assets, you can build and deploy without interruptions.
 
At Sparkle Web, we specialize in resolving complex app build issues and improving deployment pipelines for faster releases.
 

Need expert help fixing build or Play Console issues? Let us Flutter & DevOps team, streamline your process and eliminate build-time errors.

    Author

    • Owner

      Mohit Kokane

      A highly skilled Flutter Developer. Committed to delivering efficient, high-quality solutions by simplifying complex projects with technical expertise and innovative thinking.

    Contact Us

    Free Consultation - Discover IT Solutions For Your Business

    Unlock the full potential of your business with our free consultation. Our expert team will assess your IT needs, recommend tailored solutions, and chart a path to success. Book your consultation now and take the first step towards empowering your business with cutting-edge technology.

    • Confirmation of appointment details
    • Research and preparation by the IT services company
    • Needs assessment for tailored solutions
    • Presentation of proposed solutions
    • Project execution and ongoing support
    • Follow-up to evaluate effectiveness and satisfaction

    • Email: info@sparkleweb.in
    • Phone Number:+91 90331 80795
    • Address: 303 Capital Square, Near Parvat Patiya, Godadara Naher Rd, Surat, Gujarat 395010