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

FingerprintManager.isHardwareDetected() crashes only on Android 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)

添加android.permission.USE_BIOMETRIC

我之前添加的权限如下

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

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

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

所有 OS 版本都运行良好。

干净的构建(或只是重建)也可以。