一些奇怪的android错误

时间:2016-05-24 21:43:50

标签: android opencv

https://github.com/mustafaakin/image-matcher

我使用AndroidStudio的“导入Eclipse Studio项目”导入了这个项目。编辑.properties'OpenCV - x.x.x'到'opencv'。这是错误:

checkDigits(01, [1])

1 个答案:

答案 0 :(得分:1)

正如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: 档案|项目结构| 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

<强>更新

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