Cant add openCV module as a dependency to my app

Viewed 397

I'm trying to add the OpenCV library to my app, I downloaded the latest version 4.5.2 from SourceForge.

I add it module using File>New>Import Module and selecting OpenCV-android-sdk/sdk/java as all the online instructions suggest.

Then I go Project Structure>Dependencies to add that module as a dependency, but the module I just added doesn't how up. And its crazy cuz in the window behind it you can see that it see’s my added OpenCv module, but it somehow doesn't recognize it as a module that can be depended on. I know I can manually add it in build.gradle, but the end result is not working and I have feeling there’s a correlation between this issue and the bigger problem.

enter image description here

Is there something special the module need to contain in order for Android Studio to see it as a real module that can be depended on?

1 Answers

Turns out that all of the instructions on how to add openCV to Android are out dated. They are all based on an older version of openCV that require you to import the the .../sdk/java subfolder of the sdk you download.

But in the latest openCv download that folder doesn't have a build.gradle file, and thus android Studio auto generates one for it. But this autogenerated build.gradle doesn't have the right settings for the module to work properly and be seen by AS as a depend-able module.

The solution is to import the whole ../sdk folder

Related