Android Studio找不到opencv模块,但是可以编译 [英] Android Studio can't find opencv modules, but compiles ok
问题描述
我的项目编译正常,但Android Studio感到恐慌,因为它认为找不到opencv的模块:
My project compiles fine, but Android Studio panics because it thinks it can't find opencv's modules:
OpenCV作为单独的模块包含在内,并且作为依赖项列出.据我所知,一切都很好. OpenCV的build.gradle
如下:
OpenCV is included as a separate module, and it's listed as a dependency. As far as I can tell it's all set up fine. OpenCV's build.gradle
is 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's going on? I'm not too bugged as I said, it compiles and runs absolutely fine. It is very annoying though.
推荐答案
最后破解了这个.遵循一些在线指南(我现在不记得是哪一个),我将opencv安装到了项目中的/libraries/opencv/
中.问题在于代码位于目录./src/main/java/org/opencv/[module]
中,这导致了类路径问题.
Finally cracked this one. Following some online guides (I can't remember now which one), I'd installed opencv into /libraries/opencv/
in my project. The problem was that the code was in the directory ./src/main/java/org/opencv/[module]
, and this was causing classpath problems.
为解决此问题,我将./src/main/java/org
移到了./src/org
.我是在文件管理器中完成此操作的,而不是在Android Studio中完成的,然后重新构建了项目.
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 fine, and all the errors are gone.
这篇关于Android Studio找不到opencv模块,但是可以编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!