为什么ZXING Camera不会在更高的API 25或更高版本中显示

时间:2018-02-14 01:43:11

标签: android android-gradle device zxing

我有两个Android手机三星S5 API 19和另一个设备API 25.在我的情况下,我使用ZXING开发扫描仪,它成功显示相机和工作在设备API 19,但当我在更高版本的设备Android测试Nougat API 25。该应用程序不显示相机。我将目标sdk更改为API 26但仍然无法正常工作,我检查了Manifest并且我还声明了相机权限。请帮帮我。

的build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.example.administrator.copy"
        minSdkVersion 16
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

        useLibrary 'org.apache.http.legacy'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
allprojects {
    repositories {
        // ...
        maven { url "https://jitpack.io" }
    }

    dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        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:26.+'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'

        //scanner camera library
        compile 'me.dm7.barcodescanner:zxing:1.9'

        //sweetalert dialog library
        compile 'cn.pedant.sweetalert:library:1.3'

        //login and retrieving data library
        compile 'com.android.volley:volley:1.0.0'

        testCompile 'junit:junit:4.12'
    }
}

1 个答案:

答案 0 :(得分:0)

您需要为相机添加运行时权限,以使其在api级别> = 23(Marshmallow 6.0)的设备上运行。 试试this。这将很容易使用,你可以快速设置。