Skip to content

Commit

Permalink
Fix 16K alignment for Android build (#2996)
Browse files Browse the repository at this point in the history
  • Loading branch information
louwers authored Nov 6, 2024
1 parent d939eb0 commit 32c1ab1
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/android-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ jobs:
cp MapLibreAndroidTestApp/build/outputs/apk/drawable/release/MapLibreAndroidTestApp-drawable-release.apk .
cp MapLibreAndroidTestApp/build/outputs/apk/androidTest/drawable/release/MapLibreAndroidTestApp-drawable-release-androidTest.apk .
# https://developer.android.com/guide/practices/page-sizes
- name: Check alignment of .apk
run: |
unzip -o MapLibreAndroidTestApp/build/outputs/apk/drawable/release/MapLibreAndroidTestApp-drawable-release.apk -d /tmp/my_apk_out
scripts/check-alignment.sh /tmp/my_apk_out
- name: Create artifact for benchmark APKs
uses: actions/upload-artifact@v4
with:
Expand Down
4 changes: 4 additions & 0 deletions platform/android/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

## 11.6.1

### 🐞 Bug fixes

- Fix 16K alignment Android builds ([#2995](https://github.com/maplibre/maplibre-native/issues/2995)).

### ✨ Features and improvements

- Allow configuring a `Call.Factory` instead of a `OkHttpClient` ([https://github.com/maplibre/maplibre-native/pull/2987](#2987)). Since an `OkHttpClient` can be assigned to a `Call.Factory` this should not cause any issues.
Expand Down
2 changes: 2 additions & 0 deletions platform/android/MapLibreAndroid/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ tasks.withType<DokkaTask> {
}

android {
ndkVersion = Versions.ndkVersion

defaultConfig {
compileSdk = 34
minSdk = 21
Expand Down
2 changes: 2 additions & 0 deletions platform/android/MapLibreAndroidTestApp/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ fun obtainTestBuildType(): String {
}

android {
ndkVersion = Versions.ndkVersion

compileSdk = 34

defaultConfig {
Expand Down
25 changes: 25 additions & 0 deletions platform/android/scripts/check-alignment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# usage: alignment.sh path to search for *.so files

dir="$1"

matches="$(find $dir -name "*.so" -type f)"
IFS=$'\n'

err=0

for match in $matches; do
res="$(objdump -p ${match} | grep LOAD | awk '{ print $NF }' | head -1)"
if [[ $res =~ "2**14" ]] || [[ $res =~ "2**16" ]]; then
echo -e "${match}: ALIGNED ($res)"
else
if [[ "$match" == *"x86_64"* || "$match" == *"arm64-v8a"* ]]; then
echo "ERROR:"
err=1
fi
echo -e "${match}: UNALIGNED ($res)"
fi
done

exit $err

0 comments on commit 32c1ab1

Please sign in to comment.