cargo apk
Warning This tool is deprecated in favour of
xbuild
.
Tool for creating Android packages.
Installation
From crates.io:
$ cargo install cargo-apk
From source:
$ cargo install --path cargo-apk/
Commands
build
: Compiles the current packagerun
: Run a binary or example of the local packagegdb
: Start a gdb session attached to an adb device with symbols loaded
Manifest
cargo
supports the metadata
table for configurations for external tools like cargo apk
.
Following configuration options are supported by cargo apk
under [package.metadata.android]
:
[]
# Specifies the package property of the manifest.
= "com.foo.bar"
# Specifies the array of targets to build for.
= [ "armv7-linux-androideabi", "aarch64-linux-android", "i686-linux-android", "x86_64-linux-android" ]
# Path to your application's resources folder.
# If not specified, resources will not be included in the APK.
= "path/to/resources_folder"
# Path to the folder containing your application's assets.
# If not specified, assets will not be included in the APK.
= "path/to/assets_folder"
# Name for final APK file.
# Defaults to package name.
= "myapp"
# `default` (or unspecified) - Debug symbols, if they exist, are not treated
# specially.
#
# `strip` - Debug symbols are stripped from the shared
# libraries before being copied into the APK.
#
# `split` - Functions the same as `strip`, except the debug
# symbols are written to the apk output directory
# alongside the stripped shared libraries, with
# a `.dwarf` extension.
#
# Note that the `strip` and `split` options will only have an effect if
# debug symbols are present in the `.so` file(s) produced by your build, enabling
# https://doc.rust-lang.org/cargo/reference/profiles.html#strip or
# https://doc.rust-lang.org/cargo/reference/profiles.html#split-debuginfo
# in your cargo manifest can cause debug symbols to no longer be present
# in the `.so`.
= "default"
# Folder containing extra shared libraries intended to be dynamically loaded at runtime.
# Files matching `libs_folder/${android_abi}/*.so` are added to the apk
# according to the specified build_targets.
= "path/to/libs_folder"
# The name of a Linux user ID that is shared with other apps. By
# default, Android assigns each app its own unique user ID. However, if
# this attribute is set to the same value for two or more apps, they all
# share the same ID, provided that their certificate sets are identical.
# Apps with the same user ID can access each other's data and, if
# desired, run in the same process.
= "my.shared.user.id"
# Defaults to `$HOME/.android/debug.keystore` for the `dev` profile. Will ONLY
# generate a new debug.keystore if this file does NOT exist. A keystore is never
# auto-generated for other profiles.
#
# The keystore path can be absolute, or relative to the Cargo.toml file.
#
# The environment variables `CARGO_APK_<PROFILE>_KEYSTORE` and
# `CARGO_APK_<PROFILE>_KEYSTORE_PASSWORD` can be set to a keystore path
# and keystore password respectively. The profile portion follows the same rules
# as `<cfg>`, it is the uppercased profile name with `-` replaced with `_`.
#
# If present they take precedence over the signing information in the manifest.
[<profile>]
= "relative/or/absolute/path/to/my.keystore"
= "android"
# See https://developer.android.com/guide/topics/manifest/uses-sdk-element
#
# Defaults to a `min_sdk_version` of 23 and `target_sdk_version` of 30 (or lower if the detected NDK doesn't support this).
[]
= 23
= 30
= 29
# See https://developer.android.com/guide/topics/manifest/uses-feature-element
#
# Note: there can be multiple .uses_feature entries.
[[]]
= "android.hardware.vulkan.level"
= true
= 1
# See https://developer.android.com/guide/topics/manifest/uses-permission-element
#
# Note: there can be multiple .uses_permission entries.
[[]]
= "android.permission.WRITE_EXTERNAL_STORAGE"
= 18
# See https://developer.android.com/guide/topics/manifest/queries-element#provider
[[]]
= "org.khronos.openxr.runtime_broker;org.khronos.openxr.system_runtime_broker"
# Note: The `name` attribute is normally not required for a queries provider, but is non-optional
# as a workaround for aapt throwing errors about missing `android:name` attribute.
# This will be made optional if/when cargo-apk migrates to aapt2.
= "org.khronos.openxr"
# See https://developer.android.com/guide/topics/manifest/queries-element#intent
[[]]
= ["android.intent.action.SEND"]
# See https://developer.android.com/guide/topics/manifest/queries-element#intent
# Note: there can be several .data entries.
[[]]
= "image/jpeg"
# See https://developer.android.com/guide/topics/manifest/queries-element#package
[[]]
= "org.freedesktop.monado.openxr_runtime.in_process"
# See https://developer.android.com/guide/topics/manifest/application-element
[]
# See https://developer.android.com/guide/topics/manifest/application-element#debug
#
# Defaults to false.
= false
# See https://developer.android.com/guide/topics/manifest/application-element#theme
#
# Example shows setting the theme of an application to fullscreen.
= "@android:style/Theme.DeviceDefault.NoActionBar.Fullscreen"
# Virtual path your application's icon for any mipmap level.
# If not specified, an icon will not be included in the APK.
= "@mipmap/ic_launcher"
# See https://developer.android.com/guide/topics/manifest/application-element#label
#
# Defaults to the compiled artifact's name.
= "Application Name"
# See https://developer.android.com/guide/topics/manifest/application-element#extractNativeLibs
= true
# See https://developer.android.com/guide/topics/manifest/application-element#usesCleartextTraffic
= true
# See https://developer.android.com/guide/topics/manifest/meta-data-element
#
# Note: there can be several .meta_data entries.
# Note: the `resource` attribute is currently not supported.
[[]]
= "com.samsung.android.vr.application.mode"
= "vr_only"
# See https://developer.android.com/guide/topics/manifest/activity-element
[]
# See https://developer.android.com/guide/topics/manifest/activity-element#config
#
# Defaults to "orientation|keyboardHidden|screenSize".
= "orientation"
# See https://developer.android.com/guide/topics/manifest/activity-element#label
#
# Defaults to the application's label.
= "Activity Name"
# See https://developer.android.com/guide/topics/manifest/activity-element#lmode
#
# Defaults to "standard".
= "singleTop"
# See https://developer.android.com/guide/topics/manifest/activity-element#screen
#
# Defaults to "unspecified".
= "landscape"
# See https://developer.android.com/guide/topics/manifest/activity-element#exported
#
# Unset by default, or true when targeting Android >= 31 (S and up).
= true
# See https://developer.android.com/guide/topics/manifest/activity-element#resizeableActivity
#
# Defaults to true on Android >= 24, no effect on earlier API levels
= false
# See https://developer.android.com/guide/topics/manifest/activity-element#always
= true
# See https://developer.android.com/guide/topics/manifest/meta-data-element
#
# Note: there can be several .meta_data entries.
# Note: the `resource` attribute is currently not supported.
[[]]
= "com.oculus.vr.focusaware"
= "true"
# See https://developer.android.com/guide/topics/manifest/intent-filter-element
#
# Note: there can be several .intent_filter entries.
[[]]
# See https://developer.android.com/guide/topics/manifest/action-element
= ["android.intent.action.VIEW", "android.intent.action.WEB_SEARCH"]
# See https://developer.android.com/guide/topics/manifest/category-element
= ["android.intent.category.DEFAULT", "android.intent.category.BROWSABLE"]
# See https://developer.android.com/guide/topics/manifest/data-element
#
# Note: there can be several .data entries.
# Note: not specifying an attribute excludes it from the final data specification.
[[]]
= "https"
= "github.com"
= "8080"
= "/rust-windowing/android-ndk-rs/tree/master/cargo-apk"
= "/rust-windowing/"
= "image/jpeg"
# Set up reverse port forwarding through `adb reverse`, meaning that if the
# Android device connects to `localhost` on port `1338` it will be routed to
# the host on port `1338` instead. Source and destination ports can differ,
# see the `adb` help page for possible configurations.
[]
= "tcp:1338"
If a manifest attribute is not supported by cargo apk
feel free to create a PR that adds the missing attribute.