Quick Start
Get started with OpenCV on Android in minutes:Download Android SDK
Download the prebuilt OpenCV Android SDK from the releases page:The SDK includes:
- Native libraries for all Android ABIs
- Java bindings
- Sample applications
Open Sample Project
In Android Studio:
- Open File → Open
- Navigate to
opencv-android-sdk/samples - Select a sample (e.g.,
15-puzzle) - Wait for Gradle sync
Prerequisites
For building OpenCV from source:- Ubuntu/Linux
- Windows
- macOS
Install Android SDK and NDK
Using Android Studio:- Open Settings → Languages & Frameworks → Android SDK
- Check Show Package Details
- Install:
- Android SDK Platform (API 21+)
- Android NDK (version 25.x recommended)
- CMake
- Build-Tools
Supported Architectures (ABIs)
OpenCV for Android supports multiple architectures:| ABI | Architecture | Minimum API |
|---|---|---|
armeabi-v7a | ARM 32-bit with NEON | 21 |
arm64-v8a | ARM 64-bit | 21 |
x86 | Intel 32-bit | 21 |
x86_64 | Intel 64-bit | 21 |
The default configuration in
platforms/android/default.config.py builds for all four ABIs. Modern devices primarily use arm64-v8a.Building OpenCV Android SDK
Using Python Build Script
Build Options
Custom ABI Configuration
Create a custom config file:Building AAR Packages
AAR (Android Archive) packages can be imported as Gradle dependencies:Java + Shared Library AAR
Static Library AAR
For apps that bundle all dependencies:AAR packages include:
- Compiled native libraries for all ABIs
- Java wrapper classes
- ProGuard rules
- Manifest file
Integrating OpenCV into Android Apps
Method 1: Import OpenCV Module (Recommended)
Import OpenCV Module
In Android Studio:
- File → New → Import Module
- Select
opencv-android-sdk/sdk - Click Finish
Method 2: Use AAR Package
Method 3: CMake Integration
For native C++ development:build.gradle:
Using OpenCV in Code
Java/Kotlin
- Kotlin
- Java
Native C++ with JNI
Camera Integration
OpenCV providesCameraBridgeViewBase for easy camera access:
Hardware Acceleration
OpenCL Support
OpenCV can use OpenCL for GPU acceleration on Android:Qualcomm FastCV
For Qualcomm devices, enable FastCV during build:NNAPI (Neural Networks API)
For DNN module on Android 8.1+:Permissions
Add required permissions toAndroidManifest.xml:
Sample Applications
The Android SDK includes several sample applications:- 15-puzzle - Interactive puzzle game
- camera-calibration - Camera calibration tool
- color-blob-detection - Color detection
- face-detection - Face detection using Haar cascades
- image-manipulations - Basic image operations
- mobilenet-objdetect - Object detection using MobileNet
- qr-detection - QR code detection
opencv-android-sdk/samples/.
Troubleshooting
UnsatisfiedLinkError: Native libraries not found
UnsatisfiedLinkError: Native libraries not found
Ensure all ABIs are included in your APK:
OpenCVLoader.initDebug() returns false
OpenCVLoader.initDebug() returns false
- Check OpenCV module is properly imported
- Verify native libraries are in APK: Analyze APK → lib/
- Try
OpenCVLoader.initAsync()instead for Manager-based initialization
Build fails with NDK errors
Build fails with NDK errors
Camera preview shows wrong orientation
Camera preview shows wrong orientation
Set camera orientation in CameraView:Or rotate Mat manually:
App Size Optimization
Include Only Needed ABIs
Enable APK Splits
ProGuard/R8 Configuration
Add toproguard-rules.pro:
Next Steps
Camera Integration
Learn camera processing techniques
DNN on Android
Deploy deep learning models
Sample Apps
Explore example applications
Performance Tips
Optimize Android performance
