rustvncserver-android
Generic Android JNI bindings for rustvncserver - a pure Rust VNC server library.
Support this project:
Overview
This crate provides ready-to-use Android JNI bindings for the rustvncserver library. It compiles directly to a .so file that can be loaded by any Android app - no wrapper crate needed.
Key Features:
- Build-time configurable Java package via environment variables
- Flexible JNI method registration (required vs optional methods)
- Full VNC server lifecycle management
- TurboJPEG support for hardware-accelerated JPEG compression
- Works with any Android app package structure
Quick Start
1. Build the Library
# Set your Java package path
# Optional, defaults to "MainService"
# Optional, defaults to "InputService"
# Optional, defaults to "RustVNC"
# Build for Android
2. Copy to Your App
3. Add Java Native Methods
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
VNC_PACKAGE |
Yes | - | Java package path (e.g., com/mycompany/vnc) |
VNC_MAIN_SERVICE |
No | MainService |
Main service class name |
VNC_INPUT_SERVICE |
No | InputService |
Input service class name |
VNC_LOG_TAG |
No | RustVNC |
Android logcat tag |
Native Methods
Required Methods
These methods must be declared in your Java class:
// Initialize the VNC runtime (call once at startup)
private static native void ;
// Start VNC server with given dimensions, port, name, password, and HTTP root dir
private native boolean ;
// Stop the VNC server
private native boolean ;
// Check if the server is currently running
private native boolean ;
// Connect to a UltraVNC repeater
private native long ;
Optional Methods
These methods are registered only if declared in your Java class:
// Framebuffer updates
static native boolean ;
static native boolean ;
static native boolean ;
static native boolean ;
// Framebuffer info
static native int ;
static native int ;
// Clipboard
static native void ;
// Connections
static native long ;
// Client info (pass clientId from callbacks)
static native String ;
static native int ;
static native String ;
static native boolean ;
// CopyRect optimization (for scrolling/window dragging)
static native void ;
static native boolean ;
Callbacks
The library calls these static methods on your Java classes:
MainService Callbacks
public static void
public static void
public static void
public static void
InputService Callbacks
public static void
public static void
public static void
Gradle Integration
Example build.gradle task for building the Rust library:
tasks.
tasks.whenTaskAdded
Features
| Feature | Description |
|---|---|
turbojpeg |
Enable TurboJPEG for hardware-accelerated JPEG compression |
debug-logging |
Enable verbose debug logging |
TurboJPEG Setup
For turbojpeg support, you need to build libjpeg-turbo for Android. See the libjpeg-turbo Android build guide for details.
Platform Support
- Android arm64-v8a (primary target)
- Android armeabi-v7a
- Android x86_64
- Android x86
Dependencies
This crate depends on:
- rustvncserver - Pure Rust VNC server library
- jni - Rust JNI bindings
- tokio - Async runtime
- android_logger - Android logcat integration
License
Apache-2.0 - See LICENSE file for details.
Credits
- Author: Dustin McAfee
- VNC Server: rustvncserver
- Encodings: rfb-encodings
See Also
- rustvncserver - The underlying VNC server library
- RustVNC - Example Android VNC server app using this library
- RFC 6143 - RFB Protocol Specification
Android JNI bindings for rustvncserver - Build-time configurable, production ready