【问题标题】:Why ZXING Camera doesnt show in higher API 25 or higher为什么 ZXING 相机在更高的 API 25 或更高版本中不显示
【发布时间】:2018-04-15 04:14:21
【问题描述】:

我有两部 Android 手机 Samsung S5 API 19 和另一部设备 API 25。在我的情况下,我使用 ZXING 开发扫描仪,它成功显示相机并在设备 API 19 中工作,但是当我在更高版本的设备 Android 中进行测试时牛轧糖 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'
    }
}

【问题讨论】:

    标签: android android-gradle-plugin device zxing


    【解决方案1】:

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

    【讨论】:

    • 我通过在小米手机中授予相机权限解决了我的问题。小米设备具有独特的安全性。阅读此xiaomiadvices.com/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-12-31
    • 2020-07-31
    • 2017-09-21
    • 2016-09-13
    • 2016-03-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多