How can a Rust android application declare that it uses-permission?

1 week ago 7
ARTICLE AD BOX

I have a Rust application I compile for android using cargo apk build . I would like to arrange for the AndroidManifest.xml to include

<uses-permission android:name="com.oculus.feature.PASSTHROUGH" android:required="true" />

but all my attempts have failed.

Stackoverflow's AI suggests using

[package.metadata.android] permissions = [ "com.oculus.feature.PASSTHROUGH" ]

in my Cargo.toml, but that does not succeed. I have also tried

[[package.metadata.android.uses-permission]] name = "com.oculus.feature.PASSTHROUGH" required = "false"

and

[[package.metadata.android.uses-permission]] "android:name" = "com.oculus.feature.PASSTHROUGH" required = "false"

(that last one was based on modifying the cargo-apk source to derive serde::Serialize and outputting a modified manifest to see what it looked like)

None of the examples that come with the cargo-apk show how to declare permissions.

There is clearly a

#[serde(rename(serialize = "uses-permission"))] #[serde(default)] pub uses_permission: Vec<Permission>,

field in the AndroidManifest struct of ndk-build . What is the proper technique to populate it so that my application can have access to the features I want?

Read Entire Article