Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter 16 KB image support

Flutter Android App: 16KB Memory Page Compatibility Issue

I got a Google warning saying:

The app must support 16kb memory page sizes.

I tested the app on an emulator that uses X86_64, which is compatible with 16kb image sizes, and I got the error message:

This app isn't 16kb compatible. ELF alignment check failed. This app will be run using page size compatible mode...

What I've tried:

  • Updated NDK to: 27.0.12077973
  • Updated AGP to: 8.6.0
  • Upgraded Flutter from 3.24.5 to 3.29.2
  • Upgraded to Android Studio 2025.1.3.7

After these updates, when I launch the app on the emulator, I no longer get the warning message, but with the APK analyzer, the libraries are still 4KB.

I can't use an ARM 64 emulator because they appear as unsupported system image:

I don't get any error messages or warnings anymore, so I'm lost on what to do next.

My Configuration:

pubspec.yaml dependencies:

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^1.0.6
  provider: ^6.1.2
  flutter_svg: ^2.0.10+1
  image_picker: ^1.1.2
  shared_preferences: ^2.5.3
  flutter_rating_bar: ^4.0.0
  toastification: 2.3.0
  intl: 0.19.0
  dropdown_button2: ^2.3.9
  path_provider: ^2.1.4
  uuid: ^4.5.1
  dio: ^5.7.0
  get: ^4.6.6
  drift: ^2.20.3
  jwt_decode: ^0.3.1
  drift_flutter: ^0.2.0
  material_design_icons_flutter: ^7.0.7296
  json_annotation: ^4.9.0
  logging: ^1.2.0
  sqlite3: ^2.5.0
  sqlite3_flutter_libs: ^0.5.24
  package_info_plus: ^8.0.2
  connectivity_plus: ^6.1.5
  photo_view: ^0.15.0
  flutter_localization: ^0.2.1
  intl_utils: ^2.8.7
  camera: ^0.11.0+2
  permission_handler: ^12.0.1
  image_gallery_saver_plus: ^4.0.1
  camera_android_camerax: ^0.6.12+1
  camera_platform_interface: ^2.9.0
  network_info_plus: ^6.1.3
  logging_appenders: ^1.3.1
  flutter_email_sender: ^7.0.0
  mailer: ^6.4.1
  image_painter: ^0.7.1
  image: ^4.0.17
  flutter_exif_rotation: ^0.5.2
  sensors_plus: ^6.1.1
  flutter_bloc: ^9.1.0
  web_socket_channel: ^3.0.2
  equatable: ^2.0.7
  flutter_local_notifications: ^19.4.1
  percent_indicator: ^4.2.5
  dashed_circular_progress_bar: ^0.0.6
  build_runner: ^2.4.13
  flutter_image_compress: ^2.1.0

dev_dependencies:
  flutter_test:
    sdk: flutter
  drift_dev: ^2.9.0
  json_serializable: ^6.6.2
  exif: ^3.3.0

android/gradle.properties:

org.gradle.jvmargs=-Xmx6144m -XX:MaxMetaspaceSize=1024m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

android.useAndroidX=true
android.enableJetifier=false
android.nonTransitiveRClass=false
android.nonFinalResIds=false
flutter.minSdkVersion=21
flutter.targetSdkVersion=35
flutter.compileSdkVersion=35

android.ndkVersion=27.0.12077973

org.gradle.daemon=true
org.gradle.parallel=true
org.gradle.configureondemand=false
org.gradle.caching=true

android.enableR8.fullMode=true
android.enableResourceOptimizations=true

android.bundle.language.enableSplit=false
android.bundle.density.enableSplit=false
android.bundle.abi.enableSplit=true

android.experimental.enableNewResourceShrinker=true
android.experimental.legacyTransform=false

android.ndk.useUnifiedHeaders=true

android.suppressUnsupportedCompileSdk=35

android/app/build.gradle:

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def keystoreFile = rootProject.file('key.properties')
def keystoreProperties = new Properties()
if (keystoreFile.exists()) {
    keystoreProperties.load(new FileInputStream(keystoreFile))
}

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

android {
    namespace "com.prosol.prosol"
    compileSdk 35
    ndkVersion "27.0.12077973"

    buildFeatures {
        buildConfig true
    }

    compileOptions {
        coreLibraryDesugaringEnabled = true
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_11.toString()
    }

    defaultConfig {
        applicationId "com.prosol.prosol"
        multiDexEnabled = true
        minSdkVersion 21
        targetSdkVersion 35
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName

        ndk {
            abiFilters 'arm64-v8a', 'x86_64'
        }
    }

    signingConfigs {
        release {
            storeFile file(keystoreProperties['storeFile'])
            storePassword keystoreProperties['storePassword']
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
        }
    }

    buildTypes {
        debug {
            signingConfig signingConfigs.debug
            buildConfigField "String", "GIT_COMMIT", "\"${getGitCommit()}\""
            buildConfigField "String", "GIT_BRANCH", "\"${getGitBranch()}\""
        }

        release {
            signingConfig signingConfigs.release
            minifyEnabled false
            shrinkResources false
            buildConfigField "String", "GIT_COMMIT", "\"${getGitCommit()}\""
            buildConfigField "String", "GIT_BRANCH", "\"${getGitBranch()}\""
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

            ndk {
                debugSymbolLevel 'SYMBOL_TABLE'
            }
        }
    }

    packaging {
        jniLibs {
            // CRITICAL: useLegacyPackaging = false 
            useLegacyPackaging = false

            // Résolution des conflits de bibliothèques
            pickFirsts += ['**/libc++_shared.so']
            pickFirsts += ['**/libsqlite3.so']
            pickFirsts += ['**/libsqlite3_flutter_libs.so']
            pickFirsts += ['**/libdrift_sqlite3.so']

            // Préservation des symboles pour débogage
            keepDebugSymbols += ['*/arm64-v8a/*.so']
            keepDebugSymbols += ['*/x86_64/*.so']
        }

        resources {
            // Exclusions META-INF
            excludes += ['META-INF/DEPENDENCIES']
            excludes += ['META-INF/LICENSE']
            excludes += ['META-INF/LICENSE.txt']
            excludes += ['META-INF/NOTICE']
            excludes += ['META-INF/NOTICE.txt']
        }
    }

    // Configuration lint
    lint {
        checkReleaseBuilds = false
        abortOnError = false
    }
}

static def getGitCommit() {
    try {
        return 'git rev-parse --short HEAD'.execute().text.trim()
    } catch (Exception e) {
        return "unknown"
    }
}

static def getGitBranch() {
    try {
        return 'git rev-parse --abbrev-ref HEAD'.execute().text.trim()
    } catch (Exception e) {
        return "unknown"
    }
}

flutter {
    source '../..'
}

dependencies {
    coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5'
    implementation project(':cameraxmodule')
}

Question:

How can I properly configure my Flutter Android app to support 16KB memory page sizes? What additional steps do I need to take beyond updating NDK, AGP, and Flutter versions?

like image 240
Moctar Traoré Avatar asked Feb 17 '26 11:02

Moctar Traoré


1 Answers

It's required ndk r28 or newer to compile 16KB by default
https://developer.android.com/guide/practices/page-sizes?authuser=2#compile-r28

I do not sure. Did you have to update some lib or not. Because I using image_picker 1.1.2 But I can build on Pre-Release 16KB ARM SDK and APK Analyzer also 16KB Alignment
**Update**
After I try many thing I have to update my answer. We have to update some lib If you using VSCode It have extension call Version Lens can help you which lib have new version and you have to looking for is lib that have platform code
enter image description here

like image 131
Lightn1ng Avatar answered Feb 20 '26 03:02

Lightn1ng



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!