-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Closed
Description
System Information
Tested with several OpenCV versions:
- OpenCV Releases OpenCV – 4.8.0
- current version 4.x (SHA d36b959)
Brief information
We have to use code fixes to include OpenCV to Android Studio project. Adding OpenCV should work without code fixes.
You could use this guide or https://medium.com/@ankitsachan/android-studio-kotlin-open-cv-16d75f8d9969 to import OpenCV.
Detailed description
Error1
Need add this code to MyApplication/opencv/build.gradle (fix from this):
plugins {
id 'org.jetbrains.kotlin.android' version '1.7.10'
}
Otherwise, this error will occur:
Error2
Need add this code to MyApplication/opencv/build.gradle (fix from this):
buildFeatures{
aidl true
buildConfig true
}
Otherwise, this error will occur:
These errors were reproduced there:
- https://stackoverflow.com/questions/73225714/import-opencv-sdk-to-android-studio-chipmunk
- https://stackoverflow.com/questions/76374886/error-cannot-find-symbol-import-org-opencv-buildconfig-android-studio
- https://forum.opencv.org/t/task-compiledebugjavawithjavac-failed/13667/4
Steps to reproduce
Build OpenCV for Android:
export ANDROID_NDK_HOME=/home/alexander/Android/Sdk/ndk/18.1.5063045/
export ANDROID_SDK=/home/alexander/Android/Sdk/
export ANDROID_NDK_HOME=/home/alexander/Android/Sdk/ndk/18.1.5063045/
python /home/alexander/all/opencv/opencv/platforms/android/build_sdk.py /home/alexander/all/opencv/opencv/build_2/ /home/alexander/all/opencv/opencv --ndk_path /home/alexander/Android/Sdk/ndk/18.1.5063045/ --sdk_path /home/alexander/Android/Sdk/ --config /home/alexander/all/opencv/opencv/platforms/android/ndk-18-api-level-21.config.py
or download OpenCV Android sdk from OpenCV Releases
and add OpenCV to empty Android Studio project.

You could use this guide to add OpenCV.
Issue submission checklist
- I report the issue, it's not a question
- I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
- I updated to the latest OpenCV version and the issue is still there
- There is reproducer code and related data files (videos, images, onnx, etc)
Reactions are currently unavailable

