Skip to content

Commit 1dbdf0c

Browse files
authored
[android][docs] Update to latest info (swiftlang#83611)
1 parent 5e24617 commit 1dbdf0c

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

docs/Android.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,17 @@ on an Android device, it takes a lot more than just the Swift stdlib to write
2222
an app. You'd need some sort of framework to build a user interface for your
2323
application, which the Swift stdlib does not provide.
2424

25-
Alternatively, one could theoretically call into Java interfaces from Swift,
26-
but unlike as with Objective-C, the Swift compiler does nothing to facilitate
27-
Swift-to-Java bridging.
28-
2925
## Prerequisites
3026

3127
To follow along with this guide, you'll need:
3228

3329
1. A Linux environment capable of building Swift from source, preferably
34-
Ubuntu 22.04 or Ubuntu 20.04. Before attempting to build for Android,
30+
Ubuntu 24.04 or Ubuntu 22.04. Before attempting to build for Android,
3531
please make sure you are able to build for Linux by following the
3632
instructions in the Swift project README.
3733
2. The latest build of the Swift compiler for your Linux distro, available at
38-
https://www.swift.org/download/ or sometimes your distro package manager.
39-
3. The latest version of the Android LTS NDK (r27c at the time of this writing),
34+
https://www.swift.org/install/linux/ or sometimes your distro package manager.
35+
3. The latest version of the Android LTS NDK (r27d at the time of this writing),
4036
available to download here:
4137
https://developer.android.com/ndk/downloads
4238
4. An Android device with remote debugging enabled or the emulator. We require
@@ -54,9 +50,9 @@ and the prebuilt Swift toolchain (add --skip-early-swift-driver if you already
5450
have a Swift toolchain in your path):
5551

5652
```
57-
$ NDK_PATH=path/to/android-ndk-r27c
58-
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2024-11-09-a-ubuntu22.04/usr/bin
59-
$ git checkout swift-DEVELOPMENT-SNAPSHOT-2024-11-09-a
53+
$ NDK_PATH=path/to/android-ndk-r27d
54+
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2025-08-07-a-ubuntu24.04/usr/bin
55+
$ git checkout swift-DEVELOPMENT-SNAPSHOT-2025-08-07-a
6056
$ utils/build-script \
6157
-R \ # Build in ReleaseAssert mode.
6258
--android \ # Build for Android.
@@ -83,11 +79,12 @@ Then use the standalone Swift stdlib from the previous step to compile a Swift
8379
source file, targeting Android:
8480

8581
```
86-
$ NDK_PATH="path/to/android-ndk-r27c"
87-
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2024-11-09-a-ubuntu22.04/usr/bin
82+
$ NDK_PATH="path/to/android-ndk-r27d"
83+
$ SWIFT_PATH=path/to/swift-DEVELOPMENT-SNAPSHOT-2025-08-07-a-ubuntu24.04/usr/bin
8884
$ $SWIFT_PATH/swiftc \ # The prebuilt Swift compiler you downloaded
8985
# The location of the tools used to build Android binaries
9086
-tools-directory ${NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64/bin/ \
87+
-disallow-use-new-driver \ # Work around a bug in the driver, a fix is in the works
9188
-target aarch64-unknown-linux-android21 \ # Targeting Android aarch64 at API 21
9289
-sdk ${NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64/sysroot \ # The SDK is the Android unified sysroot and the resource-dir is where you just built the Swift stdlib.
9390
-resource-dir build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift
@@ -135,7 +132,7 @@ $ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libBlo
135132
In addition, you'll also need to copy the Android NDK's libc++:
136133

137134
```
138-
$ adb push /path/to/android-ndk-r27c/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so /data/local/tmp
135+
$ adb push /path/to/android-ndk-r27d/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so /data/local/tmp
139136
```
140137

141138
Finally, you'll need to copy the `hello` executable you built in the
@@ -178,7 +175,7 @@ $ utils/build-script \
178175
-R \ # Build in ReleaseAssert mode.
179176
-T \ # Run all tests, including on the Android device (add --host-test to only run Android tests on the Linux host).
180177
--android \ # Build for Android.
181-
--android-ndk ~/android-ndk-r27c \ # Path to an Android NDK.
178+
--android-ndk ~/android-ndk-r27d \ # Path to an Android NDK.
182179
--android-arch aarch64 \ # Optionally specify Android architecture, alternately armv7 or x86_64
183180
--android-api-level 21
184181
```

0 commit comments

Comments
 (0)