正如丹尼爾ķ已經正確地指出:
重要的Android應用程序/庫Android Studio中,要導入該項目需要的build.gradle或POM .xml文件,以便Android Studio自帶的構建系統(Gradle/Maven)可以在項目導入過程中解決依賴關係等問題...
您引用的Github項目也是這樣嗎? https://github.com/mustafaakin/image-matcher 顯然它得到了書面與Eclipse IDE ......推到Github上沒有任何build文件...
您仍然可以導入,通過手動創建一個的build.gradle文件在項目的根和然後嘗試再次導入該應用程序。
一個可能的工作的build.gradle文件(取決於你的Android Studio的搖籃插件版本等我剛纔假設你複製從你的工作項目您的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中去: 文件|項目結構| image-matcher-master |依賴關係| +
在那裏你添加你的OpenCV庫作爲「文件依賴」...如果它是一個JAR ...否則,如果你的下載文件夾中的opencv是源...你也可以在Android Studio中加載,選擇「模塊依賴」。
如果這行不通......這可能是有用的,以及: http://docs.opencv.org/3.0-beta/doc/tutorials/introduction/android_binary_package/dev_with_OCV_on_Android.html
UPDATE:
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
請記下代碼和錯誤與正確的格式,並刪除圖像 – Miki
項目是否有文件的build.gradle?因爲我沒有看到任何。 –