【问题标题】:some strange android error一些奇怪的安卓错误
【发布时间】:2016-05-25 20:23:36
【问题描述】:

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

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

/home/uttaran/Downloads/h1/h/src/main/res/layout/main_layout.xml
Error:(62) No resource identifier found for attribute 'camera_id' in package 'in.mustafaak.imagematcher'
Error:(62) No resource identifier found for attribute 'show_fps' in package 'in.mustafaak.imagematcher'
Error:Execution failed for task ':h:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/home/uttaran/Android/Sdk/build-tools/23.0.3/aapt'' finished with non-zero exit value 1
Information:BUILD FAILED

【问题讨论】:

  • 请用正确的格式写下代码和错误,并删除图像
  • 项目是否有 build.gradle 文件?因为我什么都没看到。

标签: android opencv


【解决方案1】:

正如 Daniel K 已经正确陈述的那样:

要在 Android Studio 中重要的 Android 应用程序/库,您要导入的项目需要在项目的根目录中有一个 build.gradlepom.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

【讨论】:

  • 谢谢!帮了大忙。
猜你喜欢
  • 1970-01-01
  • 2012-02-20
  • 1970-01-01
  • 2013-12-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-06-12
  • 2015-10-13
相关资源
最近更新 更多