10

I have a flutter application where very less code written in Android (Push Notification and Dynamic link). I am following Android page and using Flutter ver3.29.2.

I created a emulator with 16Kb page size support and tried to check APK against script provided by Google link.

when I run script, get following message

>   You can install the latest build-tools by running the below command 
> and updating your $PATH:
> 
>     sdkmanager "build-tools;35.0.0-rc3"
> 
> === ELF alignment ===
> -e /var/folders/dz/250bg7ws2jd88wngwmnp7ch80000gn/T/app-p-release_out_XXXXX.XkyJgo1NUC/lib/arm64-v8a/libsigner.so:
> \e[32mALIGNED\e[0m (2**14)
> -e /var/folders/dz/250bg7ws2jd88wngwmnp7ch80000gn/T/app-p-release_out_XXXXX.XkyJgo1NUC/lib/arm64-v8a/libflutter.so:
> \e[32mALIGNED\e[0m (2**16)
> -e /var/folders/dz/250bg7ws2jd88wngwmnp7ch80000gn/T/app-p-release_out_XXXXX.XkyJgo1NUC/lib/arm64-v8a/libapp.so:
> \e[32mALIGNED\e[0m (2**16)
> -e /var/folders/dz/250bg7ws2jd88wngwmnp7ch80000gn/T/app-p-release_out_XXXXX.XkyJgo1NUC/lib/arm64-v8a/libmodpng.so:
> \e[31mUNALIGNED\e[0m (2**12)
> -e /var/folders/dz/250bg7ws2jd88wngwmnp7ch80000gn/T/app-p-release_out_XXXXX.XkyJgo1NUC/lib/arm64-v8a/libmodft2.so:
> \e[31mUNALIGNED\e[0m (2**12)
> -e /var/folders/dz/250bg7ws2jd88wngwmnp7ch80000gn/T/app-p-release_out_XXXXX.XkyJgo1NUC/lib/arm64-v8a/libc++_shared.so:
> \e[31mUNALIGNED\e[0m (2**12)
> -e /var/folders/dz/250bg7ws2jd88wngwmnp7ch80000gn/T/app-p-release_out_XXXXX.XkyJgo1NUC/lib/arm64-v8a/libmodpdfium.so:
> \e[31mUNALIGNED\e[0m (2**12)
> -e /var/folders/dz/250bg7ws2jd88wngwmnp7ch80000gn/T/app-p-release_out_XXXXX.XkyJgo1NUC/lib/arm64-v8a/libdatastore_shared_counter.so:
> \e[32mALIGNED\e[0m (2**14)
> -e /var/folders/dz/250bg7ws2jd88wngwmnp7ch80000gn/T/app-p-release_out_XXXXX.XkyJgo1NUC/lib/arm64-v8a/libjniPdfium.so:
> \e[31mUNALIGNED\e[0m (2**12)

Below are list of my yaml file dependency

dependencies:
  adjust_sdk: ^5.4.2
  app_settings: ^6.1.1
  app_tracking_transparency: ^2.0.6+1
  collection: ^1.19.1
  connectivity_plus: ^6.1.5
  crypto: ^3.0.6
  encrypt: ^5.0.3
  dartz: ^0.10.1
  dio: ^5.2.1+1
  equatable: ^2.0.5
  firebase_analytics: ^12.0.0
  firebase_core: ^4.0.0
  firebase_crashlytics: ^5.0.0
  firebase_messaging: ^16.0.0
  firebase_remote_config: ^6.0.0
  flutter:
    sdk: flutter
  flutter_aepassurance: ^5.0.0
  flutter_aepcore: ^5.0.0
  flutter_aepedge: ^5.0.0
  flutter_aepedgeidentity: ^5.0.0
  flutter_appsize_generator:
    git: https://github.com/my_name/appsize_generator
  flutter_bloc: ^9.1.0
  flutter_cached_pdfview: ^0.4.3
  flutter_downloader: ^1.12.0
  flutter_html: ^3.0.0-beta.2
  flutter_inappwebview: ^6.1.5
  flutter_pdfview: ^1.4.1+1
  flutter_secure_storage: ^9.2.4
  flutter_svg: ^2.2.0
  freezed_annotation: ^3.1.0
  get_it: ^8.0.2
  go_router: ^16.2.0
  hive_flutter: ^1.1.0
  intl: ^0.19.0
  jwt_decoder: ^2.0.1
  logging: ^1.3.0
  lottie: ^3.3.1
  onetrust_publishers_native_cmp: 202507.1.1
  package_info_plus: ^8.3.1
  path_provider: ^2.0.11
  pretty_dio_logger: ^1.1.1
  share_plus: ^11.1.0
  shared_preferences: ^2.0.15
  url_launcher: ^6.1.5
  youtube_player_flutter: ^9.1.2
  custom_localization:
    path: ./packages/custom_localization
  open_file: ^3.5.10
  flutter_file_dialog: ^3.0.2
  dropdown_search: ^6.0.1

dev_dependencies:
  bloc_test: ^10.0.0
  build_runner: ^2.1.11
  flutter_launcher_icons: ^0.14.1
  flutter_lints: ^5.0.0
  flutter_test:
    sdk: flutter
  freezed: ^3.0.0-0.0.dev
  hive_generator: ^2.0.0
  mockito: ^5.3.1

flutter_appsize_generator:
  raster_size: 4
  max_size: 120

flutter:
  uses-material-design: true

How to indentify which package is causing problem. Also When I run the app, i get below screen

enter image description here

please guide if any other changed required in Android settings.

4
  • Use the APK analyze function of Android Studio to open the APK and check all the .so files for their alignment. Hopefully from the library name you can identify the dependency it belongs to. Commented Aug 20 at 20:31
  • @Robert it print out same name as we get from script. Any other way to find out please Commented Aug 20 at 21:55
  • 1
    @Gagan_iOS, please see my updated answer. It does not fix the issue, but I've concluded that flutter_pdfview package is not updated to support 16KB page size and is generating some 4KB aligned .so shared libraries. Hence, only thing you can do is ask the flutter_pdfview maintainer to update soon with the fix. You can open an issue in their github page. Added fix link to their Beta version. Commented Aug 22 at 4:55
  • @rusty many thanks, I have raised issues with flutter_pdfview Commented Aug 23 at 12:18

4 Answers 4

8

Some .so library files in the command output are 2**12 == 4KB aligned. So, the message that ELF alignment check failed.

Please check this link for detailed answer. I am posting a summary of what you need to do here:

Steps to support 16KB page alignment in Flutter app: (First of all create a backup of your original project, and try the following steps in a copy of the project. It's always good to have a backup.)

  1. As stated in the official documentation, you need to update AGP to version 8.5.1 or higher to be able to compile with 16KB page size. (Or for some reasons, if you can't upgrade your AGP, then the documentation suggests your app use compressed shared libraries. More about this in the link pointed out by @Ramiro G.M.) The documentation says to upgrade NDK version to 28 but the versions 26 and 27 also compatible. You may leave it to any among 26, 27 or 28. The respective files to edit are: android/settings.gradle and look for the line like id "com.android.application" version "8.7.3" apply false and change to compatible version, and file android/app/build.gradle where you may change the like as ndkVersion "27.0.12077973".

  2. Your project code, if contains native code, must update to support 16KB page size. To check if the shared libraries are aligned to 16 KB or more, and know if any are .so packages are aligned to 4 KB which is not what you want, you can run the command (in Mac or Linux):

    find -type f | grep '\.so$' | xargs -I{} -exec sh -c 'echo  "\n{}"; llvm-objdump-18 -p "{}" | grep "LOAD"'
    

(The llvm-objdump-18 command may be available in other forms like objdump alias.)

  1. Your project dependencies listed in pubspec.yaml file, both direct and dev dependencies may need to be updated if they depend on native code. If you can identify the individual ones, you may update only those to the appropriate version, or else you should update all the dependency packages in your pubspec.yaml file. Also, the transient dependencies should be updated. How: To update the direct and dev dependencies, update the corresponding version number to each packages in the pubspec.yaml file and after that run flutter clean; flutter pub get from the project root which will update the direct and dev dependencies listed in pubspec.yaml file. Now to upgrade the transient dependencies: You can see the table with the command: flutter pub outdated and update the transient dependencies with flutter pub upgrade command (or flutter pub upgrade --major-versions).

  2. After you've updated the dependencies, try to run the project. Additional configuration changes may be asked and displayed as error messages. You should do as suggested. You may update your question if you need help with that.

After you fix these, check again for the 16KB alignment of .so packages and also test run in 16KB compliant emulator or devices.

Note: To update the dependencies in your pubspec.yaml VS Code extensions like Version Lens can ease the process. Similar should also exist for Android Studio.

UPDATE 02:

I checked the .so files that were not compliant to 16KB page size, and found that among the packages listed in your pubspec.yaml file, package flutter_pdfview: ^1.4.1+1 was the one that was resulting in these shared libraries. I have also noted that you have the latest version of the package. I also tested with the same latest version, till date, and found the same shared libraries generated that were not 16KB compliant. These are:

libc++_shared.so
libjniPdfium.so
libmodft2.so
libmodpdfium.so
libmodpng.so

I checked with flutter pub outdated which gave the following output:


Showing outdated packages.
[*] indicates versions that are not the latest available.

Package Name              Current  Upgradable  Resolvable  Latest  

direct dependencies: all up-to-date.

dev_dependencies:        
flutter_lints             *5.0.0   *5.0.0      6.0.0       6.0.0   

transitive dependencies: 
characters                *1.4.0   *1.4.0      *1.4.0      1.4.1   
material_color_utilities  *0.11.1  *0.11.1     *0.11.1     0.13.0  
meta                      *1.16.0  *1.16.0     *1.16.0     1.17.0  

transitive dev_dependencies:
lints                     *5.1.1   *5.1.1      6.0.0       6.0.0   
test_api                  *0.7.6   *0.7.6      *0.7.6      0.7.7

Which is for a simple flutter project using flutter_pdfview and path_provider package which does not show much of the transient dependencies that we can upgrade to fix the issue. These are mostly normal transient dependencies normally found in simple flutter projects.

In conclusion, I don't see much you can do to fix this error of 16KB page size noncompliance. You should report this to the package maintainer of flutter_pdfview and should he fix this, upsteram, the only thing the package users would have to do is to upgrade the package to the one that fixes the issue. That is all we can do for now. Hope, it gets fixed earlier that Nov. 2025 before the deadline.

UPDATE 03:

I see you have already filed an issue in the flutter_pdfview's GitHub page. And for now they have suggested a beta version offering the fix:

Link to flutter_pdfview beta version offering 16KB page size fix for Android

Sign up to request clarification or add additional context in comments.

Comments

8

For those who will be struggling to find the affected 4KB aligned packages, follow these steps-

Step 1: Choose your debug APK from analyze APK menu-

Choose your debug APK

Step 2: Analyzer will show affected .so library files, those need to be fixed. (In Picture Few libraries marked which is not aligned with The 16KB Page Size)

In Picture Few libraries marked which is not aligned with The 16KB Page Size

Copy keywords from affected .so files name and In terminal run the following commands-

     cd android
     ./gradlew app:dependencies

Step 3: Search for the keywords then you will find the affected package which is using C++ native shared libraries. (In my case i am searching for droidsonroids.gif and found that its coming from Crisp Chat Package)

Affected package

2 Comments

Thank you for sharing friend...I wonder what to do though with the cases that the .so file doesn't have the same name shown inside the dependency list...Anybody knows a better way to find the specific dependency in relation to the .so file? Please let me know...thank u!
I've found this article which helped me with RootBeer detection, but still have unfindable libsigner.so dependency
4

I also had issues making my App 16kb page aligned, because of the dependencies I am using. If any of the native libraries is not 16kb aligned, it fails.

I succeeded by doing the following things:

  • Update all dependencies in my flutter app, as some of them need the latest flutter and dart version
  • Update my flutter SDK version from the 3.27.1 to 3.35.1 which has 36 targetedSDK
  • Update NDK version, Java version and AGP as they are needed for updating the flutter version
  • Update the Gradle version so the all mandatory upgrades will get completed by it

I tested this through APK analyzer and by uploading the app to closed testing to make sure that app is 16KB compatible.

Note, that updating the flutter SDK defaults increased the App size. The reason is the minimum SDK will be 24, as flutter SDK version 3.35.1 has minimum SDK 24 by default.

The native lib from the app will be unzipped which is important to make app 16kb compatible. This increases the app size, which you can see through the apk analyzer as well.

1 Comment

0

For those stuck with release, this is an alternative option to extends the 16 KB support requirements for now. Click on the notification in the Play Console for your release, go to "view details", and click the button to extend the period.

New contributor
yukang is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.