Oak experimentally supports android. As of right now, it should be possible with some workarounds to build programs with Oak that run as expected on Android, with some limitations; and these programs will likely need to have some custom settings apart from a build for other platforms. We'll be looking to improve the amount of work needed to adapt Oak to Android going forward.
How can you build a program with Oak for android? This unfortunately requires a lot of setup:
-
Download Android Studio
-
Via Android Studio's SDK manager (Setup a Project -> Tools -> SDK Manager) (we won't be using this project):
-
Specify and note the Android SDK location at the top of this window. If on windows, ensure this path does not contain spaces.
-
Download SDK Tools -> NDK (Side by side), Platform-Tools, and Build-Tools
-
Setup your environment (e.g. ~/.bash_profile) to include the following, substituting ANDROID_HOME with the noted android SDK location from before, and noting that the version strings are not likely the same as they will be on your machine:
export ANDROID_HOME=/d/android export ANDROID_NDK_HOME=$ANDROID_HOME/ndk/23.1.7779620/ export PATH=$PATH:$ANDROID_HOME/platform-tools export PATH=$PATH:$ANDROID_HOME/build-tools/32.0.0
-
Install gomobile
-
(
gomobile init
may require a C compiler) -
Run
gomobile build --target=android/arm64
from that package (other architectures may work as well, but we lack devices to test them on.) A C compiler is no longer needed at this stage. -
You may optionally provide an
AndroidManifest.xml
as described in the gomobile docs. (I have not tested this.) -
From here you can use
adb
to connect to a test device and install the built apk. In my testing, the only commands needed whereadb usb
,adb install
andadb logcat
for debugging.