BarcodeScanning.Native.Maui icon indicating copy to clipboard operation
BarcodeScanning.Native.Maui copied to clipboard

Android 16 KB Pages - incompatible warning

Open bnSonic opened this issue 3 months ago • 9 comments

Google says, we need to update our Android Apps until November 2025 to support 16 KB RAM Pages. I've created an android emulator with 16 KB Pages and installed one of our apps => I got a warning that 16 KB is not supported.

so I started searching why - because a plain .net9 Maui project runs just fine.

I've added this Barcode-Scanner Package and - boom - I got the warning when installing the test-app again! So I think this library should (have to?) be updated somehow to be compatible with this new rule from google :(

Are you aware of that? Maybe it's simple as using maui 9.0.100 or higher? not sure though

If I can solve this on my own side please let me know. If you are able to make this package compatible to 16KB sizes, I would be VERY happy :)

Thanks a lot

bnSonic avatar Sep 11 '25 07:09 bnSonic

plus 1 for this!

Syed-RI avatar Sep 11 '25 07:09 Syed-RI

i also created an emulator with 16kb pages but the app runs just fine on my end, i'm using dotnet 9.0.304. it is possible that i'm just blind and didn't see the warning tho, but the app seems to run fine on my end

Glopex avatar Sep 11 '25 09:09 Glopex

Oh I've spent too much time debugging this today...

Initially i was thinking that my native c++ code was compiled wrong but it looks that it aligned properly. Even tried to remove it with no success.

I followed this guide and tried various .csproj changes on debug and release modes. All testing was done on BarcodeScanning.Test project. All shared libraries seem to be fine...

I'll attach the output of the zipalign tool that i ran on debug .apk file. Looks like a lot of res and misc files are misaligned. So far I don't know how to fix that... FWIW debug and release .apk files are misaligned, release .aab looks fine.

output.txt

afriscic avatar Sep 11 '25 10:09 afriscic

Hm that's strange now …

What I did:

  • I took a rather small Maui App I've built to demonstrate a bug in the collectionView and run it on the 16KB Emulator => fine
  • I deleted that App from the Emulator
  • I added this Barcode Scanner Package to the .csproj file and initialize it
<PackageReference Include="BarcodeScanning.Native.Maui" Version="2.2.1" />
...
builder.UseBarcodeScanning();
  • when I run this, the Emulator / Android tells me "it's not 16KB compatible and will run in compatibility mode" (I can see this switch enabled when I look at the App-Information on Android)

Then I deleted the app again.

  • now I cloned this repro to my local Mac. I set the $(MauiVersion) in the .csproj files fix to "9.0.100" and compiled it
  • then I replaced the PackageReference with a ProjectReference and started the App on the Emulator

=> No Message. It works 16 KB I think.

  • well, to be sure: I replaced the ProjectReference again with the PackageReference
  • I deleted the app from the emulator and started debugging again … and it still runs without warning message 😳

maybe it's some caching because I didn't change the version number? But a ProjectReference is not putting something in the nuget cache, does it?

That my workload currently:

dotnet workload list

Workloadversion: 9.0.302.0

Installierte Workload-ID      Manifestversion      Installationsquelle
----------------------------------------------------------------------
maui                          9.0.51/9.0.100       SDK 9.0.300       

bnSonic avatar Sep 11 '25 11:09 bnSonic

meanwhile I've deleted the package from ~/.nuget/packages deleted the app from the emulator run the debugger again App installed and runs … no warning now - STRANGE

I'm fine if this package is compatible with 16 KB page sizes :D it's just … why did I see the warning when I FIRST tested it? 🤔

bnSonic avatar Sep 11 '25 12:09 bnSonic

ok nevermind now i also get the warning, at this point i really don't know what to do, hope they fix it soon

Glopex avatar Sep 12 '25 13:09 Glopex

I believe recompiling and publishing the respective application again with gradle 8.5.1 (see docs) will be sufficient.

The native libs are already compatible with 16KB page sizes:

$ brew install binutils
$ objdump -p BarcodeScanning.Native.Maui/Platform/Android/Native/arm64-v8a/libInvertBytes.so | grep LOAD 
    LOAD off    0x0000000000000000 vaddr 0x0000000000000000 paddr 0x0000000000000000 align 2**14
    LOAD off    0x00000000000006e0 vaddr 0x00000000000046e0 paddr 0x00000000000046e0 align 2**14

$ objdump -p BarcodeScanning.Native.Maui/Platform/Android/Native/armeabi-v7a/libInvertBytes.so | grep LOAD
    LOAD off    0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**14
    LOAD off    0x00000480 vaddr 0x00004480 paddr 0x00004480 align 2**14

# 2**14 --> 16 KB compatible, 2^{14} = 16384 

sventropy avatar Sep 16 '25 19:09 sventropy

i am a very silly person, i did not realise that the second time i ran the application in the emulator i had switched branch to an older one i was using for the windows version of the app, with another library. The app works just fine now, no warning message. I'm using dotnet 9.0.304 with the latest version of the library and i'm testing this on a emulated pixel 9a with the 16KB page test patch. hope that helps 🙏

edit: i use visual studio to compile everything, i also tried deleting the obj and bin folder, uninstalling the old app on the emulator and recompiling everything to see if something remained cached but can confirm that it works as intended!

Glopex avatar Sep 17 '25 07:09 Glopex

also target MAUI latest. Please :)

Syed-RI avatar Sep 17 '25 07:09 Syed-RI