Skip to main content
OpenCV provides comprehensive Android support through native NDK libraries, prebuilt AAR packages, and Java/Kotlin bindings.

Quick Start

Get started with OpenCV on Android in minutes:
1

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
2

Open Sample Project

In Android Studio:
  1. Open File → Open
  2. Navigate to opencv-android-sdk/samples
  3. Select a sample (e.g., 15-puzzle)
  4. Wait for Gradle sync
3

Run on Device

  1. Connect your Android device (USB debugging enabled)
  2. Click Run (Shift+F10)
  3. Select your device
Android 5.0 (API Level 21) or higher is required.

Prerequisites

For building OpenCV from source:

Install Android SDK and NDK

Using Android Studio:
  1. Open Settings → Languages & Frameworks → Android SDK
  2. Check Show Package Details
  3. Install:
    • Android SDK Platform (API 21+)
    • Android NDK (version 25.x recommended)
    • CMake
    • Build-Tools

Supported Architectures (ABIs)

OpenCV for Android supports multiple architectures:
ABIArchitectureMinimum API
armeabi-v7aARM 32-bit with NEON21
arm64-v8aARM 64-bit21
x86Intel 32-bit21
x86_64Intel 64-bit21
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

1

Clone OpenCV

2

Set Environment Variables

3

Run Build Script

Add --config ndk-25.config.py to use a specific NDK version configuration.
4

Find Output

The SDK will be in:

Build Options

Custom ABI Configuration

Create a custom config file:
Use it:

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

1

Import OpenCV Module

In Android Studio:
  1. File → New → Import Module
  2. Select opencv-android-sdk/sdk
  3. Click Finish
2

Add Dependency

In your app’s build.gradle:
3

Update settings.gradle

Method 2: Use AAR Package

Or publish to local Maven repository:

Method 3: CMake Integration

For native C++ development:
In build.gradle:

Using OpenCV in Code

Java/Kotlin

Native C++ with JNI

Java/Kotlin side:

Camera Integration

OpenCV provides CameraBridgeViewBase for easy camera access:
Layout XML:

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 to AndroidManifest.xml:
Request runtime permissions (Android 6.0+):

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
Explore these in opencv-android-sdk/samples/.

Troubleshooting

Ensure all ABIs are included in your APK:
  1. Check OpenCV module is properly imported
  2. Verify native libraries are in APK: Analyze APK → lib/
  3. Try OpenCVLoader.initAsync() instead for Manager-based initialization
Set camera orientation in CameraView:
Or rotate Mat manually:

App Size Optimization

Include Only Needed ABIs

Enable APK Splits

ProGuard/R8 Configuration

Add to proguard-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