Skip to content

Commit f6568f9

Browse files
authored
Android 16 KB page sizes (#910)
1 parent 4bc8498 commit f6568f9

8 files changed

Lines changed: 145 additions & 29 deletions

File tree

.github/workflows/ci.yml

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,54 @@ jobs:
290290
uses: actions/checkout@v4
291291
with:
292292
submodules: true
293-
# Setup JDK 11
294-
- name: set up JDK 11
293+
# Setup JDK 17
294+
- name: set up JDK 17
295295
uses: actions/setup-java@v4
296296
with:
297-
java-version: '11'
297+
java-version: '17'
298298
distribution: 'temurin'
299+
# Ensure Gradle uses this JDK (important when toolchains are present)
300+
- name: Point Gradle at JDK 17
301+
run: echo "ORG_GRADLE_JAVA_HOME=$JAVA_HOME" >> $GITHUB_ENV
302+
303+
- name: Mirror ANDROID_HOME → ANDROID_SDK_ROOT
304+
run: echo "ANDROID_SDK_ROOT=$ANDROID_HOME" >> "$GITHUB_ENV"
305+
306+
# Install required Android components & accept licenses (NDK r28 + compileSdk 35)
307+
- name: Install Android SDK packages
308+
shell: bash
309+
run: |
310+
set -euo pipefail
311+
SDKROOT="${ANDROID_SDK_ROOT:-$ANDROID_HOME}"
312+
SDKMANAGER="$SDKROOT/cmdline-tools/latest/bin/sdkmanager"
313+
314+
# Some images have cmdline-tools already; ensure path exists
315+
if [[ ! -x "$SDKMANAGER" ]]; then
316+
echo "cmdline-tools not found; installing…"
317+
mkdir -p "$SDKROOT/cmdline-tools"
318+
curl -sSL -o /tmp/clt.zip https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
319+
sudo unzip -q /tmp/clt.zip -d "$SDKROOT/cmdline-tools"
320+
sudo mv "$SDKROOT/cmdline-tools/cmdline-tools" "$SDKROOT/cmdline-tools/latest"
321+
SDKMANAGER="$SDKROOT/cmdline-tools/latest/bin/sdkmanager"
322+
fi
323+
324+
echo "Installing platform-tools, Build-Tools 35, platform android-35, NDK r28, and CMake…"
325+
# Avoid 'yes' SIGPIPE killing the step: turn off pipefail just for these lines
326+
set +o pipefail
327+
yes | sudo "$SDKMANAGER" --install \
328+
"platform-tools" \
329+
"build-tools;35.0.0" \
330+
"platforms;android-35" \
331+
"ndk;28.0.12433566" \
332+
"cmake;3.22.1"
333+
334+
yes | "$SDKMANAGER" --licenses
335+
set -o pipefail
336+
337+
# Quick sanity prints (non-fatal)
338+
"$SDKROOT/ndk/28.0.12433566/ndk-build" -v >/dev/null 2>&1 || true
339+
"$SDKMANAGER" --list | sed -n '1,80p' || true
340+
299341
# Build and publish locally for the test app to find the SNAPSHOT version
300342
- name: Build ${{ env.PACKAGE_NAME }}
301343
run: |
@@ -311,6 +353,22 @@ jobs:
311353
cd src/test/android/testapp/src/main/assets
312354
python3 -m pip install boto3
313355
python3 ./android_file_creation.py
356+
357+
- name: Set Android keystore home
358+
run: |
359+
echo "ANDROID_SDK_HOME=$GITHUB_WORKSPACE/.android-home" >> "$GITHUB_ENV"
360+
echo "ANDROID_PREFS_ROOT=$GITHUB_WORKSPACE/.android-home" >> "$GITHUB_ENV"
361+
mkdir -p "$GITHUB_WORKSPACE/.android-home/.android"
362+
363+
- name: Create debug keystore
364+
run: |
365+
keytool -genkeypair \
366+
-keystore "$ANDROID_SDK_HOME/.android/debug.keystore" \
367+
-storepass android -keypass android \
368+
-alias androiddebugkey \
369+
-dname "CN=Android Debug,O=Android,C=US" \
370+
-keyalg RSA -keysize 2048 -validity 14000
371+
314372
- name: Build Test App
315373
run: |
316374
cd src/test/android/testapp

android/ANDROID.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ cross-platform, high-performance, secure, and reliable.
2828
## Installation
2929

3030
### Minimum requirements
31-
* Java 11+ ([Download and Install Java](https://www.java.com/en/download/help/download_options.html))
31+
* Java 17+ ([Download and Install Java](https://www.java.com/en/download/help/download_options.html))
3232
* [Set JAVA_HOME](#set-java_home)
33-
* Gradle 7.4.2 ([Download and Install Gradle](https://gradle.org/install/))
33+
* Gradle 8.5.1+ ([Download and Install Gradle](https://gradle.org/install/))
3434
* Android SDK 24 ([Doanload SDK Manager](https://developer.android.com/tools/releases/platform-tools#downloads))
3535
* [Set ANDROID_HOME](#set-android_home)
36-
* Android NDK ([Download and install Android NDK](https://developer.android.com/ndk/downloads))
36+
* Android NDK 28+ ([Download and install Android NDK](https://developer.android.com/ndk/downloads))
3737

3838
### Build and install CRT from source
3939
Supports API 24 or newer.

android/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ buildscript {
44
mavenCentral()
55
}
66
dependencies {
7-
classpath 'com.android.tools.build:gradle:7.4.2'
7+
// AGP 8.5.1+ aligns uncompressed .so at 16KB automatically
8+
// Requires JDK 17+
9+
classpath 'com.android.tools.build:gradle:8.5.1'
810
}
911
}
1012

android/crt/build.gradle

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ ext {
4343
}
4444

4545
android {
46-
compileSdk 33
47-
ndkVersion "21.4.7075529" // LTS version
46+
namespace "software.amazon.awssdk.crt"
47+
48+
compileSdk 35
49+
// Pin NDK r28+ (16KB alignment & removal of PAGE_SIZE macro are default)
50+
ndkVersion "28.0.12433566"
4851

4952
useLibrary 'android.test.runner'
5053
useLibrary 'android.test.base'
@@ -67,11 +70,32 @@ android {
6770

6871
externalNativeBuild {
6972
cmake {
73+
// If built on NDK r27 you need `-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON`
7074
arguments "-DBUILD_DEPS=ON"
7175
}
7276
}
7377
}
7478

79+
buildFeatures {
80+
// AGP 8 disables buildConfig generation by default. We set this to true
81+
// to resstore BuildConfig.VERSION_NAME for both debug and release build types.
82+
buildConfig true
83+
}
84+
85+
packagingOptions {
86+
jniLibs {
87+
// Make sure JNI libs are packaged UNCOMPRESSED (so AGP can align them)
88+
useLegacyPackaging false
89+
}
90+
}
91+
92+
publishing {
93+
// Creates the 'release' SoftwareComponent used by maven-publish
94+
singleVariant("release") {
95+
withSourcesJar()
96+
}
97+
}
98+
7599
sourceSets {
76100
main {
77101
java.srcDir '../../src/main/java'
@@ -163,8 +187,10 @@ afterEvaluate {
163187

164188
publications {
165189
release(MavenPublication) {
166-
from components.release
167-
190+
def comp = components.findByName("release")
191+
if (comp != null) {
192+
from comp
193+
}
168194
groupId = 'software.amazon.awssdk.crt'
169195
artifactId = 'aws-crt-android'
170196
version = project.hasProperty('newVersion') ? project.property('newVersion') : android.defaultConfig.versionName

codebuild/cd/release-android-maven-central.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,33 @@ phases:
66
commands:
77
- sudo add-apt-repository ppa:openjdk-r/ppa
88
- sudo apt-get update -y
9-
- sudo apt-get install openjdk-11-jdk-headless maven wget unzip -y -f
9+
10+
# Java 17 for AGP 8.x
11+
- sudo apt-get install -y openjdk-17-jdk-headless maven wget unzip gnupg
12+
- export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
13+
- export PATH="$JAVA_HOME/bin:$PATH"
14+
- export ORG_GRADLE_JAVA_HOME="$JAVA_HOME"
15+
1016
# install android sdk
11-
- wget --quiet https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip
1217
- export ANDROID_SDK_ROOT=$CODEBUILD_SRC_DIR/android-sdk
18+
- export ANDROID_HOME="$ANDROID_SDK_ROOT" # settings.gradle checks ANDROID_HOME
1319
- mkdir -p $ANDROID_SDK_ROOT/cmdline-tools
14-
- unzip commandlinetools-linux-7583922_latest.zip -d $ANDROID_SDK_ROOT/cmdline-tools
20+
- wget --quiet https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
21+
- unzip -q commandlinetools-linux-11076708_latest.zip -d "$ANDROID_SDK_ROOT/cmdline-tools"
1522
# This weird path needed for cmd tool to work
16-
- mv $ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools $ANDROID_SDK_ROOT/cmdline-tools/latest
17-
# install android build tools
18-
- echo y | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --install "build-tools;30.0.3" "platforms;android-33" "ndk;21.4.7075529"
23+
- mv "$ANDROID_SDK_ROOT/cmdline-tools/cmdline-tools" "$ANDROID_SDK_ROOT/cmdline-tools/latest"
24+
- export PATH="$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$PATH"
25+
26+
# Platform/Build-Tools for compileSdk 35, NDK r28, and CMake
27+
- yes | sdkmanager --install "platform-tools" "build-tools;35.0.0" "platforms;android-35" "ndk;28.0.12433566" "cmake;3.22.1"
28+
- yes | sdkmanager --licenses
29+
1930
pre_build:
2031
commands:
2132
- cd $CODEBUILD_SRC_DIR/aws-crt-java
2233
- export PKG_VERSION=$(git describe --tags | cut -f2 -dv)
2334
- echo $PKG_VERSION
35+
2436
# install settings.xml to ~/.m2/settings.xml
2537
- mkdir -p $HOME/.m2
2638
- aws s3 cp s3://code-sharing-aws-crt/aws-crt-java.settings.token.xml $HOME/.m2/settings.xml
@@ -37,6 +49,10 @@ phases:
3749
- sed -i 's|token-username|'"$ST_USERNAME"'|g' $HOME/.m2/settings.xml
3850
- sed -i 's|token-password|'"$ST_PASSWORD"'|g' $HOME/.m2/settings.xml
3951

52+
# Sanity prints
53+
- java -version
54+
- ./gradlew -v
55+
4056
build:
4157
commands:
4258
# update the version to match the git tag, make a staging release which we will release once snapshot testing passes
@@ -48,6 +64,7 @@ phases:
4864

4965
post_build:
5066
commands:
67+
- echo "Build & publish steps completed."
5168

5269
cache:
5370
paths:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#Wed Oct 16 16:47:56 PDT 2024
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

src/test/android/testapp/build.gradle

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
buildscript {
2-
ext.kotlin_version = '1.5.0'
2+
ext.kotlin_version = '1.9.24'
33
repositories {
44
google()
55
mavenCentral()
66
}
77
dependencies {
8-
classpath "com.android.tools.build:gradle:7.1.2"
8+
classpath "com.android.tools.build:gradle:8.5.1"
99
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1010
}
1111
}
@@ -22,8 +22,10 @@ apply plugin: 'com.android.application'
2222
apply plugin: 'kotlin-android'
2323

2424
android {
25-
compileSdkVersion 30
26-
buildToolsVersion "30.0.3"
25+
namespace "software.amazon.awssdk.crttest"
26+
27+
compileSdk 35
28+
buildToolsVersion "35.0.0"
2729

2830
useLibrary 'android.test.runner'
2931
useLibrary 'android.test.base'
@@ -32,14 +34,18 @@ android {
3234
defaultConfig {
3335
applicationId "software.amazon.awssdk.crttest"
3436
minSdkVersion 26
35-
targetSdkVersion 30
37+
targetSdkVersion 33
3638
versionCode 1
3739
versionName "1.0"
38-
ndkVersion "23.1.7779620"
3940

4041
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4142
}
4243

44+
// Ensure JNI libs from dependencies stay UNCOMPRESSED so AGP can 16KB-zip-align them
45+
packagingOptions {
46+
jniLibs { useLegacyPackaging false }
47+
}
48+
4349
sourceSets {
4450
main {
4551
java.srcDir 'src/main/java'
@@ -62,6 +68,11 @@ android {
6268
compileOptions {
6369
sourceCompatibility = 1.8
6470
targetCompatibility = 1.8
71+
coreLibraryDesugaringEnabled true
72+
}
73+
74+
kotlinOptions {
75+
jvmTarget = "1.8"
6576
}
6677
}
6778

@@ -73,6 +84,7 @@ dependencies {
7384
implementation 'androidx.core:core:1.2.0'
7485
implementation 'androidx.core:core-ktx:1.2.0'
7586
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
87+
coreLibraryDesugaring "com.android.tools:desugar_jdk_libs:1.1.5"
7688

7789
testImplementation 'junit:junit:4.13'
7890

@@ -81,8 +93,8 @@ dependencies {
8193
implementation 'junit:junit:4.13'
8294
androidTestImplementation "junit:junit:4.13"
8395

84-
androidTestImplementation "androidx.test:core:1.2.0"
96+
androidTestImplementation "androidx.test:core:1.5.0"
8597
androidTestImplementation "androidx.test:runner:1.5.2"
8698
androidTestImplementation "androidx.test:rules:1.5.0"
87-
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
99+
androidTestImplementation "androidx.test.ext:junit:1.1.5"
88100
}

src/test/android/testapp/src/main/AndroidManifest.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3-
package="software.amazon.awssdk.crttest">
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
43

54
<application
65
android:allowBackup="true"
@@ -9,7 +8,9 @@
98
android:roundIcon="@mipmap/ic_launcher_round"
109
android:supportsRtl="true"
1110
android:theme="@style/AppTheme">
12-
<activity android:name=".MainActivity">
11+
<activity
12+
android:name=".MainActivity"
13+
android:exported="true">
1314
<intent-filter>
1415
<action android:name="android.intent.action.MAIN" />
1516

0 commit comments

Comments
 (0)