Skip to content

Commit 0d2c17f

Browse files
authored
Merge pull request #8007 from xiaobai/update-android-readme
2 parents 467c8af + 9f779d4 commit 0d2c17f

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

docs/Android.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ Swift-to-Java bridging.
3030
To follow along with this guide, you'll need:
3131

3232
1. A Linux environment capable of building Swift from source, specifically
33-
Ubuntu 15.10 (Ubuntu 14.04 is [not currently supported](https://bugs.swift.org/browse/SR-1321), [nor is 16.04](https://bugs.swift.org/browse/SR-1321)).
33+
Ubuntu 16.04 or Ubuntu 15.10 (Ubuntu 14.04 has not been tested recently).
3434
The stdlib is currently only buildable for Android from a Linux environment.
3535
Before attempting to build for Android, please make sure you are able to build
3636
for Linux by following the instructions in the Swift project README.
37-
2. The latest version of the Android NDK (r13 at the time of this writing),
37+
2. The latest version of the Android NDK (r14 at the time of this writing),
3838
available to download here:
3939
http://developer.android.com/ndk/downloads/index.html.
4040
3. An Android device with remote debugging enabled. We require remote
@@ -55,7 +55,9 @@ You may download prebuilt copies of these dependencies, built for Ubuntu 15.10
5555
and Android NDK r13. Click [here](https://github.com/SwiftAndroid/libiconv-libicu-android/releases/download/android-ndk-r13/libiconv-libicu-armeabi-v7a-ubuntu-15.10-ndk-r13.tar.gz)
5656
to download, then unzip the archive file.
5757

58-
Alternatively, you may choose to build libiconv and libicu for Android yourself:
58+
Alternatively, you may choose to build libiconv and libicu for Android yourself.
59+
If you are using Ubuntu 16.04, it is suggested that you build them yourself, as the prebuilt 15.10 copies have not been tested on 16.04.
60+
The steps are as follows:
5961

6062
1. Ensure you have `curl`, `autoconf`, `automake`, `libtool`, and
6163
`git` installed.
@@ -81,7 +83,7 @@ Android NDK, as well as the directories that contain the `libicuuc.so` and
8183
$ utils/build-script \
8284
-R \ # Build in ReleaseAssert mode.
8385
--android \ # Build for Android.
84-
--android-ndk /path/to/android-ndk-r13 \ # Path to an Android NDK.
86+
--android-ndk /path/to/android-ndk-r14 \ # Path to an Android NDK.
8587
--android-api-level 21 \ # The Android API level to target. Swift only supports 21 or greater.
8688
--android-icu-uc /path/to/libicu-android/armeabi-v7a \
8789
--android-icu-uc-include /path/to/libicu-android/armeabi-v7a/icu/source/common \
@@ -102,7 +104,7 @@ gold linker in the Android NDK into your `PATH`:
102104

103105
```
104106
$ sudo ln -s \
105-
/path/to/android-ndk-r13/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin/ld.gold \
107+
/path/to/android-ndk-r14/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin/ld.gold \
106108
/usr/bin/armv7-none-linux-androideabi-ld.gold
107109
```
108110

@@ -111,10 +113,12 @@ source file, targeting Android:
111113

112114
```
113115
$ build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swiftc \ # The Swift compiler built in the previous step.
116+
# The location of the tools used to build Android binaries
117+
-tools-directory /path/to/android-ndk-r14/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin
114118
-target armv7-none-linux-androideabi \ # Targeting android-armv7.
115-
-sdk /path/to/android-ndk-r13/platforms/android-21/arch-arm \ # Use the same NDK path and API version as you used to build the stdlib in the previous step.
116-
-L /path/to/android-ndk-r13/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a \ # Link the Android NDK's libc++ and libgcc.
117-
-L /path/to/android-ndk-r13/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9 \
119+
-sdk /path/to/android-ndk-r14/platforms/android-21/arch-arm \ # Use the same NDK path and API version as you used to build the stdlib in the previous step.
120+
-L /path/to/android-ndk-r14/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a \ # Link the Android NDK's libc++ and libgcc.
121+
-L /path/to/android-ndk-r14/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/4.9 \
118122
hello.swift
119123
```
120124

@@ -155,7 +159,7 @@ $ adb push build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/android/libswi
155159
In addition, you'll also need to copy the Android NDK's libc++:
156160

157161
```
158-
$ adb push /path/to/android-ndk-r13/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so /data/local/tmp
162+
$ adb push /path/to/android-ndk-r14/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so /data/local/tmp
159163
```
160164

161165
Finally, you'll need to copy the `hello` executable you built in the
@@ -164,7 +168,7 @@ previous step:
164168
$ adb push hello /data/local/tmp
165169
```
166170

167-
### 4. Running "Hello, world" on your Android device
171+
### 5. Running "Hello, world" on your Android device
168172

169173
You can use the `adb shell` command to execute the `hello` executable on
170174
the Android device:

0 commit comments

Comments
 (0)