Example for Rust Android Native Development

Related tags

GUI rust-ndk-example
Overview

Example for Rust Android Native Development

用 Rust 开发 Android 控制台应用程序的样板工程。

环境准备

安装 rust,确保 rustup, cargo 可用。

安装 Android NDK, 路径设为 ANDROID_NDK_HOME 环境变量。

添加 android 的 arm64 平台 target, 安装 cargo-xdk (桥接 Cargo 和 Android NDK; 注意 cargo-ndk 项目不支持编译为可执行程序):

rustup target add aarch64-linux-android
cargo install cargo-xdk

创建项目

假设项目叫做 foo

cd ~/work/rust_projects
cargo new foo # 创建可执行程序为目标的工程,放在 foo 目录
cd foo
vim src/main.rs

编译运行

export ANDROID_NDK_HOME=${ANDROID_NDK}

# 默认的编译输出目录
cargo xdk -t arm64-v8a build --release
adb push target/aarch64-linux-android/release/foo /data/local/tmp/
adb shell "cd /data/local/tmp; chmod +x ./foo; ./foo"

# 或者: 另行拷贝输出到 jniLibs 目录
cargo xdk -t arm64-v8a -o ./jniLibs build --release
adb push jniLibs/arm64-v8a/foo /data/local/tmp
adb shell "cd /data/local/tmp; chmod +x ./foo; ./foo"

截图

References

You might also like...
Crate for simple implementation of Component for Native API 1C:Enterprise written in rust

Гайд по использованию на русском языке можно посмотреть здесь и задать вопросы по использованию, но не оставляйте там комментарии об ошибках, т.к. там

Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.
Simple and portable (but not inflexible) GUI library in C that uses the native GUI technologies of each platform it supports.

libui: a portable GUI library for C This README is being written. Status It has come to my attention that I have not been particularly clear about how

OS-native file dialogs on Linux, OS X and Windows
OS-native file dialogs on Linux, OS X and Windows

nfd-rs nfd-rs is a Rust binding to the library nativefiledialog, that provides a convenient cross-platform interface to opening file dialogs on Linux,

A tiny, neat C library that portably invokes native file open and save dialogs.
A tiny, neat C library that portably invokes native file open and save dialogs.

Native File Dialog A tiny, neat C library that portably invokes native file open, folder select and save dialogs. Write dialog code once and have it p

OS native dialogs for Windows, MacOS, and Linux

💾 nfd2 nfd2 is a Rust binding to the nativefiledialog library, that provides a convenient cross-platform interface to opening file dialogs on Windows

Native Maps for Web, Mobile and Desktop
Native Maps for Web, Mobile and Desktop

mapr Native Maps for Web, Mobile and Linux A map rendering library written in Rust. Example | Book | API | Chat in Matrix Space Project State This pro

Generate Anchor IDL for Native Solana Programs.

Native Solana To Anchor IDL Autogenerate Anchor IDL from programs written in Native Solana. Disclaimer The instructions must follow strict set of rule

Provides core language-agnostic functionality for LiveView Native across platforms

LiveView Native Core This repository contains an implementation of the LiveView Native core library, which is intended to handle all the details which

An example of searching iBeacon using gtk-rs and btleplug.
An example of searching iBeacon using gtk-rs and btleplug.

Beacon Searcher Screenshot Compile & Run Install GTK 3 dev packages: macOS: $ brew install gtk+3 $ brew install gnome-icon-theme Debian / Ubuntu: $ s

Owner
Zhuo Zhang
What I cannot create I do not understand
Zhuo Zhang
Vviz - Rapid prototyping GUI, and visual printf-style debugging for computer vision development.

vviz Rapid prototyping GUI, and visual printf-style debugging for computer vision development. Its core dependencies are egui and Miniquad. For a full

Hauke Strasdat 20 Dec 15, 2022
D3D11 backend for egui library. Presumably for mods/cheats development

D3D11 backend for egui library. Presumably for mods/cheats development. Currently few features from egui are missing. WIP.

sy1ntexx 24 Jan 4, 2023
A template to kickstart your Cairo 1.0 development

Cairo 1 template How to use Install Rust Click the "Use this template" button to use this as a basis for your repo or create a codespace on Github. To

Extropy.io 4 Dec 23, 2022
A data-first Rust-native UI design toolkit.

Druid A data-first Rust-native UI toolkit. Druid is an experimental Rust-native UI toolkit. Its main goal is to offer a polished user experience. Ther

null 8.2k Dec 31, 2022
Rust bindings to the minimalist, native, cross-platform UI toolkit `libui`

Improved User Interface A cross-platform UI toolkit for Rust based on libui iui: ui-sys: iui is a simple (about 4 kLOC of Rust), small (about 800kb, i

Rust Native UI Group 865 Dec 27, 2022
Truly cross platform, truly native. multiple backend GUI for rust

WIP: Sauron-native a rust UI library that conquers all platforms ranging from desktop to mobile devices. An attempt to create a truly native, truly cr

Jovansonlee Cesar 627 Jan 5, 2023
Cross-platform native Rust menu library

A cross-platform Rust library for managing the native operating system menus.

Mads Marquart 16 Jan 6, 2023
Native Rust library for FastCGI

The FastCGI Rust implementation. Description gfcgi is a native Rust library for FastCGI. This library supports multithreaded socket listeners and HTTP

Andrey Gridchin 9 Aug 7, 2022
Winsafe-examples - Examples of native Windows applications written in Rust with WinSafe.

WinSafe examples This repo contains several examples of native Win32 applications written in Rust with WinSafe. All examples follow the same program s

Rodrigo 40 Dec 14, 2022
Windows Native Undocumented API for Rust Language 🔥

Windows Native   The Windows-Native Rust library provides a convenient and safe way to access the native Windows undocumented APIs using the Rust prog

null 3 Aug 22, 2023