FingerprintManager.isHardwareDetected()仅在Android Oreo上崩溃

时间:2018-06-06 09:51:04

标签: android android-8.0-oreo

当手动请求指纹传感器的权限时,无法显示oreo对话框。

我在Manifest中列出了USE_FINGERPRINT权限,但仍然有例外

    W/System.err: java.lang.SecurityException: Must have android.permission.USE_FINGERPRINT permission.: Neither user 10190 nor current process has android.permission.USE_FINGERPRINT.
        at android.os.Parcel.readException(Parcel.java:2004)
        at android.os.Parcel.readException(Parcel.java:1950)
        at android.hardware.fingerprint.IFingerprintService$Stub$Proxy.isHardwareDetected(IFingerprintService.java:465)
        at android.hardware.fingerprint.FingerprintManager.isHardwareDetected(FingerprintManager.java:835)
        at ""ui.biometricAuth.BiometricAuth.getFingerPrintAuthError(BiometricAuth.java:174)
        at ""ui.biometricAuth.BiometricAuth.isTouchIDEnabled(BiometricAuth.java:225)
        at ""ui.usermanagement.LoginActivity.onCreate(LoginActivity.java:403)
        at android.app.Activity.performCreate(Activity.java:7036)
        at android.app.Activity.performCreate(Activity.java:7027)
 W/System.err:     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1231)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2864)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2989)
        at android.app.ActivityThread.-wrap11(Unknown Source:0)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1688)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:164)
        at android.app.ActivityThread.main(ActivityThread.java:6753)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:482)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

3 个答案:

答案 0 :(得分:0)

我在

之前添加了以下权限
<uses-permission
    android:name="android.permission.USE_FINGERPRINT"
    android:requiredFeature="false" />

现在删除android:requiredFeature =“false”并仅添加

<uses-permission android:name="android.permission.USE_FINGERPRINT" />

适用于所有操作系统版本。

答案 1 :(得分:0)

干净的构建(或只是重新构建)也适用。

答案 2 :(得分:-2)

添加android.permission.USE_BIOMETRIC