Android Studio cannot find opencv modules, but compiles ok

My project compiles fine, but Android Studio is panicking because it thinks it cannot find opencv modules:

enter image description hereenter image description here

OpenCV is included as a separate module, and it is listed as a dependency. As far as I can tell, this is all wonderful. OpenCV build.gradle as follows:

 apply plugin: 'android-library' buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.11.+' } } android { compileSdkVersion 19 buildToolsVersion "19.1" defaultConfig { minSdkVersion 8 targetSdkVersion 19 versionCode 2480 versionName "2.4.8" } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] res.srcDirs = ['res'] aidl.srcDirs = ['src'] } } } 

Any idea what is going on? I don’t listen too much, as I said, it compiles and works absolutely fine. It is very annoying though.

+6
source share
1 answer

Finally hacked this one. After some online tutorials (I can't remember which one), I installed opencv in /libraries/opencv/ in my project. The problem was that the code was in the ./src/main/java/org/opencv/[module] directory, and this caused problems with the classpath.

To solve the problem, I moved ./src/main/java/org to ./src/org . I did this in my file manager, not in Android Studio, and then rebuilt the project.

The project compiles perfectly, and all errors have disappeared.

+3
source

Source: https://habr.com/ru/post/971110/


All Articles