Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
NOTE: This library is an internal crate of the Slint project.
WARNING: This crate does not follow the semver convention for versioning and can
only be used with version = "=x.y.z"
in Cargo.toml.
Slint Android Activity Backend
This crate implements the Android backend/platform for Slint.
It uses the android-activity crate to initialize the app and provide events handling.
Status
At the moment, this is a work in progress. In the future, we expect to add features directly to the the slint crate. In the mean time, it is already possible to use this crate to test Slint applications on Android.
An example of app using it is the todo
example: https://github.com/slint-ui/slint/tree/master/examples/todo/rust
In order to try it out, edit the Cargo.toml to uncomment the #wasm#
lines, and add -p todo
to the cargo apk command bellow.
Usage
When using this crate into your project, be aware that it does not strictly adhere to semantic versioning (semver).
This means breaking changes may be introduced in any patch release.
It is crucial that the version of this crate matches the version of Slint you are using.
To specify the exact version of this crate, include the =
symbol in the version string.
You are required to add either the native-activity
or the game-activity
feature.
The native-activity
feature is a good starting point as it does not require Java stubs.
However, it is more limited and may not work well with keyboard input.
For more details, refer to the documentation of android-activity.
To create an Android build, your crate must be a library with the cdylib
crate-type.
Below is an example of how to set up your Cargo.toml
:
[]
= ["cdylib"]
[]
= { = "1.4.1", .. }
= { = "=1.4.1", = ["native-activity"] }
As with any application using android-activity
, you need to implement the android_init
function as #[no_mangle]
.
In it, create a [AndroidPlatform
] and pass it to slint::platform::set_platform
.
Here is an example:
Building and Deploying
To build and deploy your application, we suggest the usage of cargo-apk, a cargo subcommand that allows you to build, sign, and deploy Android APKs made in Rust.
You can install it and use it with the following command:
Please ensure that you have the Android NDK and SDK installed and properly set up in your development environment for the above command to work as expected.