This project is used to compile opencv into a aar module that can then be directly used in projects. Steps to create a similar project:
Ref: Android Library Doc
- Click File > New > New Module
- Click Android Library; enter the details and press Finish
- Now go to Build > Build Bundle(s)/APK(s) . This will generate the AAR
(OR)
For OpenCV, since the SDK already existed,
- Create a dummy Android project. Use Groovy builds as KTS builds do not build OpenCV properly
- Add OpenCV by Importing the module and adding it as a dependency to the app.
- Go to Project's
build.gradlefile and addid 'com.android.library' version '8.1.4' apply falsesince we are going to compile a library and not an application. Also addid 'org.jetbrains.kotlin.android' version '1.9.10' apply falsesince OpenCV requires this. - Now when we try to build, it should build
OpenCValso. But we do not need the app part since we are just going to compile the AAR - In the app's build.gradle file, remove the
include (:app)line this will ensure that the app is no longer built. You can also remove theid 'com.android.application' version '8.1.4' apply falsefrom Project'sbuild.gradleas we are no longer building the app - Open a terminal and type the below commands:
set _JAVA_OPTIONS=-Xmx512Mset JAVA_HOME=%HOME%\.jdks\corretto-17.0.9gradlew opencv:assembleRelease
- The above will get the aar built. It will be located in
opencv\build\outputs\aarfolder.
Warning: This is a student project and is not production ready. Use at your own risk.