正如 Daniel K 已经正确陈述的那样:
要在 Android Studio 中重要的 Android 应用程序/库,您要导入的项目需要在项目的根目录中有一个 build.gradle 或 pom.xml 文件这样Android Studio自带的构建系统(Gradle/Maven)就可以在项目导入的过程中解析依赖等...
你指的 Github 项目也是这个?
https://github.com/mustafaakin/image-matcher
显然它是用 Eclipse IDE 编写的...并在没有任何构建文件的情况下推送到 Github...
无论如何,您都可以导入它,方法是在项目根目录中手动创建 build.gradle 文件,然后尝试再次导入应用程序。
一个可能的工作 build.gradle 文件(取决于你的 Android Studio 的 Gradle 插件版本等。我现在假设你从你的工作项目中复制了你的 build.gradle 文件)将是:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.google.android.gms:play-services-base:8.4.0'
compile 'com.android.support:support-v4:23.3.0'
compile 'com.android.support:appcompat-v7:23.3.0'
}
如果你这样做了,它可能找不到 OpenCV 库依赖项(OpenCV 类/方法和导入中的红线),你必须进入 Android Studio:
文件 |项目结构 |图像匹配大师 |依赖 | +
然后您将您的 OpenCV 库添加为“文件依赖项”...如果它是 JAR...否则如果您的下载文件夹中的 opencv 是源...您也可以在 Android Studio 中加载它并选择“模块依赖”。
如果这不起作用......这也可能会有所帮助:
http://docs.opencv.org/3.0-beta/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html
更新:
main_layout.xml 包含以下内容:
<org.opencv.android.NativeCameraView
android:id="@+id/tutorial1_activity_native_surface_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:onClick="cameraclick"
android:visibility="gone"
opencv:camera_id="any"
android:layout_weight="1"
opencv:show_fps="true" />
所以您的 OpenCV 库带有无法找到的资源和视图,因此您的项目中的 src 结构仍然存在一些问题。
这个答案可能是相关的:
Android Studio can't find opencv modules, but compiles ok
如果没有任何效果,我建议导入一个 OpenCV Android 示例,检查它是否可以构建和编译,然后比较您的项目与示例项目的 src 结构差异...
Open the Android native Camera using OpenCV