相机权限无效

时间:2016-10-19 08:24:27

标签: android opencv gradle android-manifest opencv3.0

我正在使用OpenCV4Android 3.0.0版。我试图通过OpenCV lib访问相机,实际上我设法打开它。但我目前面临的问题是,当我创建一个新项目并导入OpenCV lib我不能使用相机,我收到以下消息时,我运行的应用程序 尽管权限已添加到清单文件中,如下所示

请告诉我运行相机的错误?

注意 我有几个项目与OpenCV导入和相机与这些项目工作正常...我面临的问题发生在今天我创建一个新项目

错误消息

enter image description here

清单

    

<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

</manifest>

OpenCVLibrary300

apply plugin: 'com.android.library'

android {
compileSdkVersion 24
buildToolsVersion "24.0.3"

defaultConfig {
    minSdkVersion 19
    targetSdkVersion 24
}

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

的build.gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
    applicationId "com.example.edgedetectionlaplace_03"
    minSdkVersion 19
    targetSdkVersion 24
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile project(':openCVLibrary300')
}

1 个答案:

答案 0 :(得分:1)

你已经把这个

<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera" android:required="false"/>
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front" android:required="false"/>
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>

现在试试这个:

Settings -> Apps -> Your app -> Permissions and enabling the Camera permission ?
然后像Qadir Hussain说的那样

kill any other apps that are using the camera.

如果无效,请检查您的设计是否与您的lib兼容。