
Using rustc to always compile your crate as a shared library by:.The android_glue crate provides FFI with the Android environment for things that are not in To show log run: cargo apk logcat | grep RustAndroidGlueStdouterr Interfacing with AndroidĪn application is not very useful if it doesn't have access to the screen, the user inputs, etc. If you only want to install, use cargo apk install. This will install your application on the emulator, then run it. It will produce an APK for each binary.Īndroid packages for bin targets are placed in target/android-artifacts//apk.Īndroid packages for example targets are placed in target/android-artifacts//apk/examples. Compiling Multiple BinariesĬargo apk build supports building multiple binaries and examples using the same arguments as cargo build. This will build an Android package in target/android-artifacts//apk. In the project root for your Android crate, run cargo apk build. Set the environment variables NDK_HOME to the path of the NDK and ANDROID_HOME to the path of the SDK.


Manual usage Setting up your environmentīefore you can compile for Android, you need to setup your environment.

Docker run -rm -v "$(pwd):/root/src" -w /root/src philipalldredge/cargo-apk cargo apk buildĭo not mount a volume on /root or you will erase the local installation of Cargo.Īfter the build is finished, you should get an Android package in target/android-artifacts/debug/apk.
