mapbox-maps-android icon indicating copy to clipboard operation
mapbox-maps-android copied to clipboard

Compile for Android with support for 16 KB page sizes

Open AndriiYanechko opened this issue 1 year ago • 1 comments

New Feature

I'm encountering an issue when I'm running the app on the Android 15 with 16 KB page size and see some native issues. Is there any plans to recompile library to resolve this issue ?

Beginning with Android 15, Android supports devices that are configured to use a page size of 16 KB (16 KB devices). If your app uses any NDK libraries, either directly or indirectly through an SDK, then you will need to rebuild your app for it to work on these 16 KB devices.

https://developer.android.com/guide/practices/page-sizes#compile-16-kb-alignment

Why

Caused by: java.lang.UnsatisfiedLinkError: dlopen failed: empty/missing DT_HASH/DT_GNU_HASH in "/data/app/~~yeqHYQLP2OTCXPdQnUQZJw==/XXXX-gZF5_v1OEhaH0PnZQDkfvg==/lib/arm64/libc++_shared.so" (new hash type from the future?)
                                                                                                    	at java.lang.Runtime.loadLibrary0(Runtime.java:1081)
                                                                                                    	at java.lang.Runtime.loadLibrary0(Runtime.java:1003)
                                                                                                    	at java.lang.System.loadLibrary(System.java:1765)
                                                                                                    	at com.mapbox.common.loader.MapboxLibraryLoader.load(MapboxLibraryLoader.kt:19)
                                                                                                    	at com.mapbox.common.CoreInitializer.create(CoreInitializer.kt:65)
                                                                                                    	at com.mapbox.common.CoreInitializer.create(CoreInitializer.kt:8)
                                                                                                    	at androidx.startup.AppInitializer.doInitialize(AppInitializer

AndriiYanechko avatar Jul 30 '24 16:07 AndriiYanechko

We're actively looking into it but we don't have a concrete timeline at the moment.

Our understanding is that no device with Android 15 will have 16kb enabled by default.

Moreover, as stated in https://developer.android.com/about/versions/15/behavior-changes-all#16-kb it won't be mandatory until next year:

We plan to make 16 KB page compatibility required for app uploads to the Google Play store next year.

jush avatar Jul 31 '24 06:07 jush

This is implemented in v11.7.X versions. Example how to fetch it: implementation 'com.mapbox.maps:android-ndk27:11.7.1'.

kiryldz avatar Nov 01 '24 19:11 kiryldz

@kiryldz If we use the implementation 'com.mapbox.maps:android-ndk27:11.7.1', do we also still keep the implementation implementation 'com.mapbox.maps:android:11.7.1' ?

PavlosTze avatar Nov 04 '24 15:11 PavlosTze

@kiryldz If we use the implementation 'com.mapbox.maps:android-ndk27:11.7.1', do we also still keep the implementation implementation 'com.mapbox.maps:android:11.7.1' ?

No, com.mapbox.maps:android-ndk27:11.7.1 should replace the default one com.mapbox.maps:android:11.7.1. They are the same in terms of API and starting from 11.7.0 we will always release 2 variants of our SDK. It is up to users to decide which one to use.

kiryldz avatar Nov 04 '24 15:11 kiryldz

@kiryldz If we use the implementation 'com.mapbox.maps:android-ndk27:11.7.1', do we also still keep the implementation implementation 'com.mapbox.maps:android:11.7.1' ?

No, com.mapbox.maps:android-ndk27:11.7.1 should replace the default one com.mapbox.maps:android:11.7.1. They are the same in terms of API and starting from 11.7.0 we will always release 2 variants of our SDK. It is up to users to decide which one to use.

I see, and except the issue described by the author above, why should someone would choose the NDK version istead of the default one? Sorry, just trying to understand as I'm getting a different crash and understand how that works in order to solve this or open a new issue.

PavlosTze avatar Nov 04 '24 15:11 PavlosTze

FYI task reference here: https://github.com/mapbox/mapbox-maps-android/issues/2506

PavlosTze avatar Nov 05 '24 12:11 PavlosTze

@kiryldz If we use the implementation 'com.mapbox.maps:android-ndk27:11.7.1', do we also still keep the implementation implementation 'com.mapbox.maps:android:11.7.1' ?

No, com.mapbox.maps:android-ndk27:11.7.1 should replace the default one com.mapbox.maps:android:11.7.1. They are the same in terms of API and starting from 11.7.0 we will always release 2 variants of our SDK. It is up to users to decide which one to use.

I see, and except the issue described by the author above, why should someone would choose the NDK version istead of the default one? Sorry, just trying to understand as I'm getting a different crash and understand how that works in order to solve this or open a new issue.

There is no practical need to use NDK 27 artifacts now. However Google strongly advises SDK developers to provide NDK 27 support ASAP because in the future there will be devices on the marker which are shipped with 16 Kb page support. Maps SDK is the first Mapbox SDK that has received this support. Noting that we provide NDK 27 support in separate artifacts as in theory misaligned NDKs in end user application might lead to runtime issues.

kiryldz avatar Nov 06 '24 12:11 kiryldz

This is implemented in v11.7.X versions. Example how to fetch it: implementation 'com.mapbox.maps:android-ndk27:11.7.1'.

I am currently using version 10.18.0 of the library. Could you please let me know if there are any plans to add support for 16 KB page sizes in the 10.x series? If so, do you have an estimated timeline for its release?

hiteshchopra11 avatar Nov 20 '24 10:11 hiteshchopra11

@hiteshchopra11 we're actively working on it but there's no timeline I can share at the moment.

jush avatar Nov 20 '24 14:11 jush

@hiteshchopra11 Maps v10.19.0 with 16 Kb support are released.

kiryldz avatar Dec 13 '24 13:12 kiryldz

Thank you so much, @jush and @kiryldz! We’re eagerly awaiting 16kb support for the Mapbox Search SDK, as this issue is currently blocking our progress :)

hiteshchopra11 avatar Jan 08 '25 07:01 hiteshchopra11

☝️ Same - https://github.com/mapbox/mapbox-search-android/issues/270

AndriiYanechko avatar Jan 08 '25 13:01 AndriiYanechko

As a reminder, this is going to be mandatory starting November 1st, 2025

https://android-developers.googleblog.com/2025/05/prepare-play-apps-for-devices-with-16kb-page-size.html?m=1

The main SDK dependency still does not appartently support the 16 kB memory page size

Image

bamsbamx avatar May 16 '25 08:05 bamsbamx

@bamsbamx I am not sure what do you mean as "main" artefact. We release NDK 27 builds with 16kb with every release both for v10 and v11 for quite a while. The new artifacts are available by appending -ndk27 to the artifact ID (for example, com.mapbox.maps:android-ndk27:10.19.0).

kiryldz avatar May 27 '25 07:05 kiryldz

@bamsbamx I am not sure what do you mean as "main" artefact. We release NDK 27 builds with 16kb with every release both for v10 and v11 for quite a while. The new artifacts are available by appending -ndk27 to the artifact ID (for example, com.mapbox.maps:android-ndk27:10.19.0).

Yes but other libraries such as the search one, doesn't have an ndk version yet therefore not only we can't use them, we can't use the maps one as well because of conflicts.

PavlosTze avatar May 27 '25 07:05 PavlosTze

@kiryldz I meant the only dependency listed in the official Mapbox docs Step 2: Add Maps SDK Dependencies

dependencies {
  ...
  implementation("com.mapbox.maps:android:11.12.2")
  ...
}

With this dependency (without using the android-ndk27 version), I get the following warning in Google Play console

Image

Is this mentioned in the Mapbox Android SDK docs? Maybe I missed it.

I am just curious. Why is the 'main' artifact (com.mapbox.maps:android:11.12.2) already compiled with 16 KB support? I mean, shouldn't this one be already compatible, without needing to declare the android-ndk27 version? This can be confusing, generating issues like #2635

Thank you for your attention

bamsbamx avatar May 27 '25 08:05 bamsbamx

@bamsbamx let me answer your question:

  1. Bumping an NDK is technically a major breaking change as NDK toolchain should be considered as an internal dependency and bumping from NDK 23 to NDK 27 including compilation flags to support 16Kb pages is a pretty big bump. For users having other 3d party libraries with C++ built with NDK 23 bumping our Maps to NDK 27 would result in hard catching runtime crashes due to libc++_shared.so being not aligned.
  2. Our SDK is used not only with the application developers (who mostly distribute apps via Google Play) but also with customers who distribute their applications directly and / or even have custom AOSP (e.g. automotive customers) who do not have this upcoming limitation.
  3. We have an internal task to update official installation docs about NDK 27 and this is expected to land soon.

@PavlosTze this repo is for Maps only and we track internally updating other components like Search and Navigation.

kiryldz avatar May 27 '25 09:05 kiryldz

@kiryldz Nice explanation! Regarding point 1, does this mean that we cannot use NDK 23 compiled libs if we are using NDK 27 compiled Mapbox lib?

bamsbamx avatar May 28 '25 08:05 bamsbamx

  1. We have an internal task to update official installation docs about NDK 27 and this is expected to land soon.

How has the progress been on this over the last month? We have a need for the NDK 27 Android version to flow into the Flutter SDK. Will both land soon?

timshadel avatar Jun 27 '25 15:06 timshadel

When will navigation be supported?

EvanZch avatar Jul 14 '25 10:07 EvanZch

@EvanZch it's already supported in v3.11.0-beta.1. You just need to update your dependencies by appending the -ndk27 postfix.

alekseyld avatar Jul 14 '25 17:07 alekseyld

@EvanZch它在v3.11.0-beta.1中已经受支持。你只需要通过附加-ndk27后缀来更新你的依赖项。

Will v2 be supported?

EvanZch avatar Jul 16 '25 09:07 EvanZch

I've already updated all the things mentioned above, but I'm still getting this error in my application (still not supported 16 KB issue). I think there's something missing in the new build version, or maybe it'll be fixed in the next update?

Image

What i installed in my apps :

Image

Not all library already updated to 16 KB:

Image

kevinmf1 avatar Aug 02 '25 04:08 kevinmf1

  1. We have an internal task to update official installation docs about NDK 27 and this is expected to land soon.

Hi! Any updates about this? I'm in the same situation as @kevinmf1 and I don't know if I have to configure my build to use ndk-build

luis-telesforo avatar Aug 05 '25 17:08 luis-telesforo

@kevinmf1 could you please check your APK with the steps described in https://developer.android.com/guide/practices/page-sizes#alignment-use-script ?

jush avatar Aug 12 '25 20:08 jush

Hi @jush I already check my app with alignment use script provided by Google Team, and here's the result:

Image

Just in case you need clear result, here is:

=== ELF alignment === /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/armeabi-v7a/libmapbox-common.so: \e[31mUNALIGNED\e[0m (212) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/armeabi-v7a/libmapbox-maps.so: \e[31mUNALIGNED\e[0m (212) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/armeabi-v7a/libSearchCore.so: \e[31mUNALIGNED\e[0m (212) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/armeabi-v7a/libc++_shared.so: \e[31mUNALIGNED\e[0m (212) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/armeabi-v7a/libdatastore_shared_counter.so: \e[32mALIGNED\e[0m (214) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/armeabi-v7a/libyuv-decoder.so: \e[31mUNALIGNED\e[0m (212) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86/libmapbox-common.so: \e[31mUNALIGNED\e[0m (212) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86/libmapbox-maps.so: \e[31mUNALIGNED\e[0m (212) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86/libSearchCore.so: \e[31mUNALIGNED\e[0m (212) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86/libc++_shared.so: \e[31mUNALIGNED\e[0m (212) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86/libdatastore_shared_counter.so: \e[32mALIGNED\e[0m (214) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86/libyuv-decoder.so: \e[31mUNALIGNED\e[0m (212) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/arm64-v8a/libmapbox-common.so: \e[32mALIGNED\e[0m (214) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/arm64-v8a/libmapbox-maps.so: \e[32mALIGNED\e[0m (214) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/arm64-v8a/libSearchCore.so: \e[32mALIGNED\e[0m (214) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/arm64-v8a/libc++_shared.so: \e[32mALIGNED\e[0m (214) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/arm64-v8a/libdatastore_shared_counter.so: \e[32mALIGNED\e[0m (214) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/arm64-v8a/libyuv-decoder.so: \e[31mUNALIGNED\e[0m (212) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86_64/libmapbox-common.so: \e[32mALIGNED\e[0m (214) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86_64/libmapbox-maps.so: \e[32mALIGNED\e[0m (214) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86_64/libSearchCore.so: \e[32mALIGNED\e[0m (214) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86_64/libc++_shared.so: \e[32mALIGNED\e[0m (214) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86_64/libdatastore_shared_counter.so: \e[32mALIGNED\e[0m (214) /var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86_64/libyuv-decoder.so: \e[31mUNALIGNED\e[0m (212) \e[31mFound 12 unaligned libs (only arm64-v8a/x86_64 libs need to be aligned).\e[0m

I hope this issue will be solved as soon as possible, as the max deadline given by Google is in the early November, Thank You.

kevinmf1 avatar Aug 21 '25 09:08 kevinmf1

Thanks @kevinmf1 for providing your output.

From the output I can see that all the required Mapbox libraries are ALIGNED properly. Please note the last message of your output:

Found 12 unaligned libs (only arm64-v8a/x86_64 libs need to be aligned).

Especially:

only arm64-v8a/x86_64 libs need to be aligned

All the Mapbox libraries for arm64-v8a are aligned:

/var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/arm64-v8a/libmapbox-common.so: \e[32mALIGNED\e[0m (214)
/var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/arm64-v8a/libmapbox-maps.so: \e[32mALIGNED\e[0m (214)
/var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/arm64-v8a/libSearchCore.so: \e[32mALIGNED\e[0m (214)

as well as the x86_64:

/var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86_64/libmapbox-common.so: \e[32mALIGNED\e[0m (214)
/var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86_64/libmapbox-maps.so: \e[32mALIGNED\e[0m (214)
/var/folders/9z/h64l1bx125sblwd2c6qqgykc0000gp/T/app-debug_out_XXXXX.haoIrQVtfR/lib/x86_64/libSearchCore.so: \e[32mALIGNED\e[0m (214)

You seem to have some other dependency (not a Mapbox one) that it is not aligned: libyuv-decoder.so

jush avatar Aug 27 '25 07:08 jush

Hi! We have updated our guidelines to highlight NDK 27 artifacts for 16 KB page size support. Simply add the -ndk27 suffix to artifact ID:

dependencies {
  ...
  implementation("com.mapbox.maps:android-ndk27:11.14.3")
  ...
}

More information about NDK support for Mapbox Maps SDK can be found here.

natiginfo avatar Sep 02 '25 08:09 natiginfo

HI @natiginfo

I'm testing right now, but i have problem on compilation and duplicate class. Here is my versions mapbox = "11.14.3" mapboxNavigation = "3.11.4" mapboxDirection = "7.7.0" mapboxSearch = "2.14.0"

mapbox-maps = { group = "com.mapbox.maps", name = "android-ndk27", version.ref = "mapbox" } mapbox-extension = { group = "com.mapbox.extension", name = "maps-compose", version.ref = "mapbox" } mapbox-navigation = { group = "com.mapbox.navigationcore", name = "android", version.ref = "mapboxNavigation" } mapbox-direction = { group = "com.mapbox.mapboxsdk", name = "mapbox-sdk-services", version.ref = "mapboxDirection" } mapbox-autocomplete = { group = "com.mapbox.search", name = "place-autocomplete", version.ref = "mapboxSearch" } mapbox-search = { group = "com.mapbox.search", name = "mapbox-search-android-ui", version.ref = "mapboxSearch" }

I also tested with -ndk27 on extension and search but no success.

DrikABrak avatar Sep 02 '25 12:09 DrikABrak

I got this to work yesterday. Here is what my toml looks like:

[versions]

mapbox = "11.14.3"
mapboxSearchAndroid = "2.14.0"


[libraries]

mapbox-maps = { module = "com.mapbox.maps:android-ndk27", version.ref = "mapbox" }
extension-maps-compose = { module = "com.mapbox.extension:maps-compose-ndk27", version.ref = "mapbox" }
mapbox-search-android = { module = "com.mapbox.search:mapbox-search-android-ndk27", version.ref = "mapboxSearchAndroid" }

moshegutman avatar Sep 02 '25 15:09 moshegutman