OpenCV with Android Studio



Download OpenCV for Android from

Download and Install Android Studio from



  1. Open Android Studio File -> New Project
  2. Select No Activity and Finish.
  3. Create a folder called “libraries” inside your Android Studio project, and copy the folder sdk/java to this folder. Rename it to “opencv”.
  4. Now, inside this “opencv” folder, create a build.gradle file, with the following content:
  5. Edit your gradlefile in your application’s main directory and add this line:
  6. Tools -> Android -> Sync Project with Gradle files
  7. Go to File -> Project Structure, inside Modules pick your ‘app’, then from the Tab pick: Dependencies, click + to add new dependency, pick Module Dependency, and add :library:opencv dependency to your project. Click OK.
  8. Create a jniLibs folder in the /app/src/main/ location and copy the all the folders from the OpenCV Android SDK/native/libs folder here.
  9. Sync again and build it.

To run OpenCV sample applications:

  • Delete java and res folders from app/src/main.
  • Go to the OpenCV for Android/samples and copy res and src folder and manifest file from any sample and paste them in your app/src/main.
  • Rename src to java.
  • Build and run.Here’s the application running

For OpenCV with Eclipse tutorial, go here.


  1. Pingback: OpenCV with Android on Eclipse | SensoVision Systems

  2. Victor

    Great tutorial, got it working in here! Can you please make one on how to run OpenCV samples with jni files? For instance face detection sample. Thank you very much!

    1. admin

      Thank you. Working on OpenCV with Android NDK. Will let you know once it finishes.


Leave a Comment

Your email address will not be published. Required fields are marked *