-
Notifications
You must be signed in to change notification settings - Fork 16
Building for Android
The macchina.io REMOTE SDK, including WebTunnelAgent
and the other command-line tools can be built for Android.
Prerequisites:
- Android NDK
- CMake (normally included with Android NDK)
- GNU Make (must be installed)
- OpenSSL (must be built)
The following instructions are based on a Debian-based Docker image (saschpe/android-ndk) with the Android NDK preinstalled in /opt/android-sdk-linux/
, building for an ARM 32-bit target (armeabi-v7a
) with API level 29 (Android 10). Commands will need to be adjusted if the NDK is installed in a different location.
We'll use a volume out
where we'll copy the final executables to.
$ docker run --rm -v "$(pwd)"/out:/root/out -it saschpe/android-ndk:jdk11_api31_30.0.3_ndk23.1.7779620_cmake3.18.1 bash
$ apt-get update && apt-get install -y make curl
Go to root/home directory:
$ cd
$ curl https://www.openssl.org/source/openssl-1.1.1q.tar.gz >openssl-1.1.1q.tar.gz
$ tar xfz openssl-1.1.1q.tar.gz
$ cd openssl-1.1.1q
$ export ANDROID_NDK_HOME=/opt/android-sdk-linux/ndk/23.1.7779620/
$ export PATH=$PATH:$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin/
$ ./Configure android-arm -D__ANDROID_API__=29
$ make
$ cd
Note: other targets for Configure
are android-arm64
, android-x86
and android-x86_64
.
Use the right one for your target device.
$ git clone https://github.com/my-devices/sdk.git
$ mkdir sdk-build
$ cd sdk-build
$ /opt/android-sdk-linux/cmake/3.18.1/bin/cmake -H/root/sdk -G'Ninja' -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/opt/android-sdk-linux/cmake/3.18.1/bin/ninja -DCMAKE_TOOLCHAIN_FILE=/opt/android-sdk-linux/ndk/23.1.7779620/build/cmake/android.toolchain.cmake -DANDROID_NATIVE_API_LEVEL=29 -DANDROID_ABI=armeabi-v7a -DOPENSSL_ROOT_DIR=/root/openssl-1.1.1q -DCMAKE_FIND_ROOT_PATH=/
$ /opt/android-sdk-linux/cmake/3.18.1/bin/ninja
$ cp bin/* ~/out
Note: for other targets, adjust the ANDROID_ABI
variable passed to cmake
(armeabi-v7a
, arm64-v8a
, x86
, x86_64
).
The resulting binaries will be in the ~/out
directory on your host machine.
Actually running WebTunnelAgent
on an Android device is a different story...
If you build your own Android image, you can include the executable in the image and
run it at startup as a daemon. For normal devices, you may have to wrap this in an APK,
possibly creating a Java wrapper application that launches WebTunnelAgent
.