错误:包android.hardware.camera2不存在OpenCV

use*_*347 21 android opencv opencv4android

我正在尝试将OpenCV模块添加到项目中,但我无法解决一些问题.这是我的app.gradle档案:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 17
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.sveder.cardboardpassthrough"
        minSdkVersion 8
        targetSdkVersion 21
    }

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

dependencies {
    compile 'com.android.support:support-v4:18.0.0'
    compile files('libs/cardboard.jar')
    compile project(':openCVLibrary')
}
Run Code Online (Sandbox Code Playgroud)

这是build.gradleOpenCV(3.0)模块的文件:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 17
    buildToolsVersion "23.0.2"

defaultConfig {
    minSdkVersion 8
    targetSdkVersion 21
}

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

正如您所看到的,我的应用程序和OpenCV gradle文件匹配,但每当我尝试构建项目时,我都没有错误error: package android.hardware.camera2.我究竟做错了什么?

提前致谢.

Roh*_*rya 77

更改compileSdkVersion 17为最低21(建议最新).因为在API 21android.hardware.camera2添加了.


小智 24

除了build.gradle.检查项目结构中的设置Ctrl +Alt+Shift+s.这解决了我的问题. 在此输入图像描述