简体   繁体   English

在Android Studio中导入OpenCv4Android时无法解决符号错误

[英]Cannot resolve symbol error when importing OpenCv4Android in Android Studio

I want to use OpenCV4Android in Android Studio. 我想在Android Studio中使用OpenCV4Android I downloaded OpenCV for Android from this link: http://opencv.org/downloads.html 我从这个链接下载了OpenCV for Androidhttp//opencv.org/downloads.html

But, when I try to import it, I get different errors in Camera2Renderer.java like, Cannot resolve symbol 'camera2' , Cannot resolve symbol 'CameraDevice' , Cannot resolve symbol 'Size' , and Cannot resolve symbol 'CaptureRequest' . 但是,当我尝试导入它时,我在Camera2Renderer.java中得到不同的错误, Cannot resolve symbol 'camera2'Cannot resolve symbol 'CameraDevice'Cannot resolve symbol 'Size' ,并且Cannot resolve symbol 'CaptureRequest'

I have tried both methods available here: 我在这里尝试了两种方法:

OpenCV in Android Studio Android Studio中的OpenCV

http://answers.opencv.org/question/14546/how-to-work-with-opencv4android-in-android-studio/ http://answers.opencv.org/question/14546/how-to-work-with-opencv4android-in-android-studio/

But, I get the same error. 但是,我得到了同样的错误。

Can anyone please tell me how to solve this error to be able to use openCV? 谁能告诉我如何解决这个错误才能使用openCV?

Thank you. 谢谢。

I faced the same issue while configuring OpenCV SDK with Android Studio. 我在使用Android Studio配置OpenCV SDK时遇到了同样的问题。

I am using the latest SDK build of OpenCV : OpenCV-3.1.0-android-sdk 我正在使用OpenCV的最新SDK版本:OpenCV-3.1.0-android-sdk

Please ensure that you have configured your build.gradle scripts. 请确保您已配置build.gradle脚本。

Build.gradle(Module: app) --> Build.gradle(模块:app) - >

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.2"

defaultConfig {
    applicationId "com.example.dev.opencvapp"
    minSdkVersion 15
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
}
  buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      }
  }
sourceSets { main { jni.srcDirs = ['src/main/jni', 'src/main/jniLib/'] } }
}

 dependencies {
  compile fileTree(include: ['*.jar'], dir: 'libs')
  testCompile 'junit:junit:4.12'
  compile 'com.android.support:appcompat-v7:24.2.1'
  compile project(':openCVLibrary310')
  }

Build.gradle(Module: openCVLibrary310) --> Build.gradle(模块:openCVLibrary310) - >

apply plugin: 'com.android.library'

android {
  compileSdkVersion 24
  buildToolsVersion "19.1.0"

  defaultConfig {
    minSdkVersion 8
    targetSdkVersion 21
  }

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
      }
  }
}

After doing this you should be able to build the app with out any errors. 完成此操作后,您应该能够构建应用程序而不会出现任何错误。

I hope I helped you!! 我希望我帮助你!!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM