An Android application that generates Microsoft Word (.docx) documents with text and images using a Rust-powered backend. Built with Jetpack Compose and Rust via JNI.
- βοΈ Multi-line Text Input - Write your content directly in the app
- πΌοΈ Multiple Image Support - Add multiple images from your gallery
- ποΈ Image Preview - See thumbnail previews of selected images
- π Custom Save Location - Choose where to save your documents
- π Fast Generation - Rust-powered document creation
- π Auto-Open - Automatically opens generated documents
- Editable text field for content input
- Horizontal image gallery showing selected images
- Add Image button for gallery selection
- Generate Document button to create and save .docx files
- Kotlin 2.1.0
- Jetpack Compose 1.7.6 (Modern declarative UI)
- Material Design Components
- Coil 2.5.0 (Image loading)
- Android SDK 35 (Target), 21 (Minimum)
- Rust - Core document generation logic
- docx-rs 0.2.14 - Word document creation
- JNI - Java Native Interface bridge
- rifgen - Rust-to-Java code generation
- Gradle 8.11.1
- Android Gradle Plugin 8.7.3
- Cargo (Rust package manager)
- Android NDK 29.0.14206865
- JDK 21 - Java Development Kit 21 or higher
- Android Studio Hedgehog (2023.1.1) or later
- Rust 1.70+ with
rustup - Android NDK 29+ installed via Android Studio SDK Manager
- Android SDK with API level 35
- macOS, Linux, or Windows
- 8GB RAM minimum (16GB recommended)
- 10GB free disk space
- Android 5.0 (Lollipop - API 21) or higher
- Storage permission for saving documents
- Media permission for selecting images
git clone https://github.com/yourusername/DocxGenerator.git
cd DocxGenerator# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Add Android targets
rustup target add aarch64-linux-android
rustup target add armv7-linux-androideabi# macOS (using Homebrew)
brew install openjdk@21
# Linux (Ubuntu/Debian)
sudo apt install openjdk-21-jdk
# Windows
# Download from https://adoptium.net/- Open Android Studio β SDK Manager
- Under SDK Platforms, install Android 15.0 (API 35)
- Under SDK Tools, install:
- Android SDK Build-Tools 34
- Android SDK Platform-Tools
- NDK (Side by side) - version 29+
- Android SDK Command-line Tools
Update docx_lib/.cargo/config.toml with your NDK path:
[target.aarch64-linux-android]
ar = "/path/to/Android/sdk/ndk/29.0.14206865/toolchains/llvm/prebuilt/YOUR-PLATFORM/bin/llvm-ar"
linker = "/path/to/Android/sdk/ndk/29.0.14206865/toolchains/llvm/prebuilt/YOUR-PLATFORM/bin/aarch64-linux-android21-clang"
[target.armv7-linux-androideabi]
ar = "/path/to/Android/sdk/ndk/29.0.14206865/toolchains/llvm/prebuilt/YOUR-PLATFORM/bin/llvm-ar"
linker = "/path/to/Android/sdk/ndk/29.0.14206865/toolchains/llvm/prebuilt/YOUR-PLATFORM/bin/armv7a-linux-androideabi21-clang"Replace:
/path/to/Android/sdkwith your Android SDK locationYOUR-PLATFORMwithdarwin-x86_64(macOS),linux-x86_64(Linux), orwindows-x86_64(Windows)
echo "sdk.dir=/path/to/Android/sdk" > local.propertiesReplace /path/to/Android/sdk with your actual Android SDK path:
- macOS:
~/Library/Android/sdk - Linux:
~/Android/Sdk - Windows:
C:\\Users\\YourUsername\\AppData\\Local\\Android\\Sdk
# Set Java 21 as active JDK
export JAVA_HOME=/path/to/java-21
# Build using Gradle wrapper
./gradlew assembleDebugOutput location: app/build/outputs/apk/debug/app-debug.apk
./gradlew assembleRelease- Open the project in Android Studio
- File β Project Structure β SDK Location β verify Android SDK and NDK paths
- Build β Build Bundle(s) / APK(s) β Build APK(s)
Solution: Ensure you're using Java 21
java -version # Should show version 21
export JAVA_HOME=/path/to/java-21Solution: Install NDK via Android Studio SDK Manager and update .cargo/config.toml
Solution: Create local.properties with correct SDK path
- Download
docx-generator-debug.apkfrom Releases - Enable Install from Unknown Sources in Settings
- Install the APK
- Grant required permissions
- Storage - To save generated .docx files
- Media/Photos - To select images from gallery
- Enter Text - Type your document content in the text field
- Add Images - Tap "Add Image" to select from gallery (repeat for multiple images)
- Preview - View selected image thumbnails in the horizontal gallery
- Generate - Tap "Generate Document"
- Choose Location - Select where to save the .docx file
- Done! - Document opens automatically
DocxGenerator/
βββ app/ # Android app module
β βββ src/main/
β β βββ java/.../MainActivity.kt # Main UI & logic
β β βββ res/ # Resources
β β βββ AndroidManifest.xml
β βββ build.gradle # App dependencies
βββ docx_lib/ # Rust library
β βββ src/
β β βββ lib.rs # Rust library entry point
β β βββ docx_glue.rs # JNI bindings (generated)
β βββ .cargo/config.toml # Rust Android build config
β βββ Cargo.toml # Rust dependencies
β βββ build.rs # Build script
βββ releases/ # Pre-built APKs
β βββ docx-generator-debug.apk
βββ build.gradle # Root build config
βββ settings.gradle # Project settings
βββ README.md # This file
User Input (Compose UI)
β
MainActivity (Kotlin)
β
JNI Bridge
β
Rust Library (docx_lib)
β
docx-rs (Document Creation)
β
.docx File Output
- Jetpack Compose UI
- Text input management
- Image selection handling
- Document generation coordination
new()- Create document builderadd_text(text)- Add text paragraphadd_image(path, width, height)- Add imagegenerate_docx(path)- Save document
- Generated by
rifgenandflapigen - Provides Kotlin/Java API for Rust functions
- Handles memory management across language boundary
# Android instrumented tests
./gradlew connectedAndroidTest
# Unit tests
./gradlew test
# Rust tests
cd docx_lib
cargo testProblem: Gradle sync fails
# Solution: Clear caches
./gradlew clean
rm -rf .gradle .idea build app/buildProblem: Rust compilation fails
# Solution: Clean Rust artifacts
cd docx_lib
cargo cleanProblem: NDK not found
# Solution: Check NDK installation
ls $ANDROID_SDK_ROOT/ndk/
# Update .cargo/config.toml with correct pathProblem: App crashes on image selection
- Solution: Grant media permissions in Settings
Problem: Document not saving
- Solution: Grant storage permissions and ensure valid save location
Problem: Native library not found
- Solution: Rebuild app to regenerate .so files
./gradlew clean assembleDebug- Modify Rust Library (
docx_lib/src/lib.rs) - Rebuild to regenerate JNI bindings
- Update UI in
MainActivity.kt - Test on device/emulator
- Kotlin: Follow Android Kotlin style guide
- Rust: Run
cargo fmtbefore committing
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For issues and questions:
- Open an Issue
- Check existing Discussions
- docx-rs - Rust library for .docx generation
- rifgen - Rust JNI bindings generator
- Jetpack Compose - Modern Android UI toolkit
- Coil - Image loading library
Status: Active Development π
Version: 1.0.0
Last Updated: October 2025
Made with β€οΈ using Kotlin, Rust, and Jetpack Compose