Skip to content

[shared_preference] Flutter lib is not 16KB page ready anymore for its Android implementation shared_preferences_android: 2.4.20 due to androidx.datastore:datastore: 1.2.0 #182898

Closed as duplicate

Description

@ext-ftite-bd

Steps to reproduce

Using latest flutter shared_preferences: ^2.5.4 . or even ^2.5.3 - the flutter Android application is not longer 16KB page compatible for arm64-v8a or x86_64 architectures - as per Android Studio Panda 1 | 2025.3.1 Patch 1 > Build > Analyze APK tool

This is caused by "libdatastore_shared_counter.so" as not 16KB ready - that comes from the shared_preferences package, through its Android implementation "shared_preferences_android:2.4.20", that was updated to use a newer version of native android lib "androidx.datastore:datastore:1.2.0" – that provides the native "libdatastore_shared_counter.so" as not compatible with 16KB page support.

OBS:
1- looking at the updates history for "shared_preferences_android" we can see that the update from version 2.4.19 to 2.4.20 also updated the native lib "androidx.datastore:datastore" version from 1.1.7 (16KB ready) to 1.2.0 (16KB not ready). Thus something broke the 16KB support in ver 1.2.0 of datastore lib, since it was ok in 1.1.7

2 - considering the OBS(1) - I've found a temp workaround - to add a force resolution strategy in flutter project "android/build.gradle", to force the usage of ver 1.1.7 for androidx.datastore:XXX libs.
I've done some tests and seen no side effects with this workaround, including on dedicated 16KB - ARM and x86 emulators, but this is still ugly and potential error prone - and we should not be forced to use it.

// Force DataStore 1.1.7 for 16K page size compatibility (1.2.0 .so is incompatible) project.configurations.all { resolutionStrategy { force 'androidx.datastore:datastore:1.1.7' force 'androidx.datastore:datastore-android:1.1.7' force 'androidx.datastore:datastore-core:1.1.7' force 'androidx.datastore:datastore-core-android:1.1.7' force 'androidx.datastore:datastore-preferences:1.1.7' force 'androidx.datastore:datastore-preferences-android:1.1.7' } }

For my project - I will consider this workaround to be used ONLY if this bug is not fixed in time in the shared pref flutter lib itself - when 16KB builds will be imposed for play-store release. So please fix it in time :)

Expected results

shared_preferences: - to fully support 16KB page size for all common architectures ARM and x86_64

Actual results

shared_preferences: - no longer supports 16KB page size for all common architectures ARM and x86_64 - due to 16KB page incompatible version used for native android lib "androidx.datastore:datastore:1.2.0"

Code sample

  • create a simple flutter app - with support for Android - using Android Studio
  • add shared_preferences: ^2.5.4 as flutter dependency in main flutter pubspec.yaml
  • build apk with android studio -release or debug
  • analyze the resulted APK with Android Studio > Build > Analyze APK > select your APK
  • wait for the tool to finish the analysis and check 16KB page support warnings

Screenshots or Video

Image Image

Logs

Flutter Doctor output

[✓] Flutter (Channel stable, 3.38.9, on macOS 26.3 xxxxx darwin-arm64, locale en-US) [1,241ms]
• Flutter version 3.38.9 on channel stable at /Users/xxxxx/Library/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 67323de (4 weeks ago), 2026-01-28 13:43:12 -0800
• Engine revision 587c18f
• Dart version 3.10.8
• DevTools version 2.51.1
• Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations, enable-native-assets, omit-legacy-version-file, enable-lldb-debugging

[✓] Android toolchain - develop for Android devices (Android SDK version 36.1.0) [5.1s]
• Android SDK at /Users/xxxxx/Library/Android/sdk
• Emulator version 36.4.9.0 (build_id 14788078) (CL:N/A)
• Platform android-36.1, build-tools 36.1.0
• ANDROID_HOME = /Users/xxxxx/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
This is the JDK bundled with the latest Android Studio installation on this machine.
To manually set the JDK path, use: flutter config --jdk-dir="path/to/jdk".
• Java version OpenJDK Runtime Environment (build 21.0.9+-14649483-b1163.86)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 26.2) [3.2s]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 17C52
• CocoaPods version 1.16.2

[✓] Chrome - develop for the web [5ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Connected device (4 available) [6.7s]
• SM G990B2 (mobile) • xxxxxxxxx • android-arm64 • Android 16 (API 36)
• BDiPhone12 (mobile) • xxxxxxxxxxxxxxxxx • ios • iOS 26.2.1 xxxxx
• macOS (desktop) • macos • darwin-arm64 • macOS 26.3 xxxxx darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 145.0.7632.116

[✓] Network resources [797ms]
• All expected network resources are available.

• No issues found!

Activity

  1. Menaitech commented on Mar 3, 2026

    @Menaitech

    i have solved it by adding the following in gardle app to solve for a temporary period

    implementation('androidx.datastore:datastore') {
    version {
    strictly '1.1.7'
    }
    }

    implementation('androidx.datastore:datastore-preferences') {
    version {
    strictly '1.1.7'
    }
    }

  2. github-actions commented on Mar 17, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  3. locked as resolved and limited conversation to collaborators on Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions