java.lang.IllegalStateException on launches after enrolling fingerprints
mariotaku opened this issue · 31 comments
I'm not sure whether it's a bug of emulator image or this sample. Here's the stack trace.
E/AndroidRuntime( 3043): FATAL EXCEPTION: main
E/AndroidRuntime( 3043): Process: com.example.android.fingerprintdialog, PID: 3043
E/AndroidRuntime( 3043): java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=0, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.example.android.fingerprintdialog/com.example.android.fingerprintdialog.MainActivity}: java.lang.RuntimeException: java.security.InvalidAlgorithmParameterException: java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
E/AndroidRuntime( 3043): at android.app.ActivityThread.deliverResults(ActivityThread.java:3699)
E/AndroidRuntime( 3043): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742)
E/AndroidRuntime( 3043): at android.app.ActivityThread.-wrap16(ActivityThread.java)
E/AndroidRuntime( 3043): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)
E/AndroidRuntime( 3043): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 3043): at android.os.Looper.loop(Looper.java:148)
E/AndroidRuntime( 3043): at android.app.ActivityThread.main(ActivityThread.java:5417)
E/AndroidRuntime( 3043): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 3043): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
E/AndroidRuntime( 3043): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
E/AndroidRuntime( 3043): Caused by: java.lang.RuntimeException: java.security.InvalidAlgorithmParameterException: java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
E/AndroidRuntime( 3043): at com.example.android.fingerprintdialog.MainActivity.createKey(MainActivity.java:232)
E/AndroidRuntime( 3043): at com.example.android.fingerprintdialog.MainActivity.onRequestPermissionsResult(MainActivity.java:109)
E/AndroidRuntime( 3043): at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:6553)
E/AndroidRuntime( 3043): at android.app.Activity.dispatchActivityResult(Activity.java:6432)
E/AndroidRuntime( 3043): at android.app.ActivityThread.deliverResults(ActivityThread.java:3695)
E/AndroidRuntime( 3043): ... 9 more
E/AndroidRuntime( 3043): Caused by: java.security.InvalidAlgorithmParameterException: java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
E/AndroidRuntime( 3043): at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:238)
E/AndroidRuntime( 3043): at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi$AES.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:53)
E/AndroidRuntime( 3043): at javax.crypto.KeyGenerator.init(KeyGenerator.java:189)
E/AndroidRuntime( 3043): at com.example.android.fingerprintdialog.MainActivity.createKey(MainActivity.java:220)
E/AndroidRuntime( 3043): ... 13 more
E/AndroidRuntime( 3043): Caused by: java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
E/AndroidRuntime( 3043): at android.security.keystore.KeymasterUtils.addUserAuthArgs(KeymasterUtils.java:115)
E/AndroidRuntime( 3043): at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:234)
E/AndroidRuntime( 3043): ... 16 more
W/ActivityManager( 1354): Force finishing activity com.example.android.fingerprintdialog/.MainActivity
We have similar issue today after updating Android Stuido(SDK, emulator) to latest version.
When the fingerprint is actually enrolled. Emulator has the following issues.
- The sample application provided by Google can't launch due to above exception
- When we try to create key in our library, it has same exception "
At least one fingerprint must be enrolled to create keys requiring user authentication for every use
"
P.S. The emulator image is Google API 23, Atom (x86_64), I tried to wipe before launch, but problem persists.
Hello,
Thanks for the report. Just to make sure, did you register at least one fingerprint in the emulator before launching the app?
I suspect it's a issue with the emulator, but wanted to make sure the precondition in case.
Hi,
Yes, I do register the fingerprint. It works before, but exception happens since I update Android
Studio this week.
Thanks.
I can also reproduce this and I believe it's an issue with the emulator, this didn't happen with a physical Nexus5x.
I raised an issue for the relevant engineer. For the time being until this is fixed, please try to use a physical device if possible. Sorry for the inconvenience.
Hi,
A new emulator image (API level 23, rev 5) should be available by now.
And this issue should not happen with that.
Please re-open this if the issue still persists.
I still get the same exception with the latest emulator image (API 23 rev 12, x86_64) after each restart of the emulator. A workaround is to delete the fingerprints and re-add them again.
I just tried the latest emulator image (API 23 rev 12, x86_64) and succeeded using the registered fingerprint.
Could you give me detailed steps and error message you encountered?
Well, I create a new AVD, API 23 rev 12 x86_64, start it, register a new fingerprint in the settings, then open the FingerprintDialog app - it works.
Then I close the emulator, start it again, open the FingerprintDialog app - it crashes.
I delete the registered fingerprint in the settings, register a new one, open the FingerprintDialog app - it works, - again, only until I restart the emulator.
Here's the exact exception message:
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: FATAL EXCEPTION: main
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: Process: com.example.android.fingerprintdialog, PID: 2464
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.fingerprintdialog/com.example.android.fingerprintdialog.MainActivity}: java.lang.RuntimeException: java.security.InvalidAlgorithmParameterException: java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.-wrap11(ActivityThread.java)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: Caused by: java.lang.RuntimeException: java.security.InvalidAlgorithmParameterException: java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at com.example.android.fingerprintdialog.MainActivity.createKey(MainActivity.java:221)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at com.example.android.fingerprintdialog.MainActivity.onCreate(MainActivity.java:99)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6237)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.-wrap11(ActivityThread.java)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: Caused by: java.security.InvalidAlgorithmParameterException: java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:238)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi$AES.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:53)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at javax.crypto.KeyGenerator.init(KeyGenerator.java:189)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at com.example.android.fingerprintdialog.MainActivity.createKey(MainActivity.java:209)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at com.example.android.fingerprintdialog.MainActivity.onCreate(MainActivity.java:99)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6237)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.-wrap11(ActivityThread.java)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: Caused by: java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.security.keystore.KeymasterUtils.addUserAuthArgs(KeymasterUtils.java:115)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:234)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi$AES.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:53)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at javax.crypto.KeyGenerator.init(KeyGenerator.java:189)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at com.example.android.fingerprintdialog.MainActivity.createKey(MainActivity.java:209)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at com.example.android.fingerprintdialog.MainActivity.onCreate(MainActivity.java:99)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.Activity.performCreate(Activity.java:6237)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.-wrap11(ActivityThread.java)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
02-01 10:25:35.700 2464-2464/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Ok, I was able to reproduce it. It's highly likely an issue with the emulator.
Sorry for the inconvenience, but if possible I recommend you to try with a physical device (Nexus5x or Nexus6p).
Fingerprints on emulators are flaky in general.
I reported the issue internally to the relevant engineer.
Sounds good, thank you.
I am getting the same issue which @dchervov dchervov gets, Is that issue fixed?
05-12 12:55:43.505 8597-8597/com.emulatorcheck E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.cts.emulatorcheck, PID: 8597
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cts.emulatorcheck/com.cts.emulatorcheck.MainActivity}: java.lang.RuntimeException: java.security.InvalidAlgorithmParameterException: java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.RuntimeException: java.security.InvalidAlgorithmParameterException: java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
at com.cts.emulatorcheck.MainActivity.createKey(MainActivity.java:302)
at com.cts.emulatorcheck.MainActivity.onCreate(MainActivity.java:149)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.security.InvalidAlgorithmParameterException: java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
atandroid.security.keystore.AndroidKeyStoreKeyGeneratorSpi.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:238)
atandroid.security.keystore.AndroidKeyStoreKeyGeneratorSpi$AES.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:53)
at javax.crypto.KeyGenerator.init(KeyGenerator.java:189)
at com.cts.emulatorcheck.MainActivity.createKey(MainActivity.java:289)
at com.cts.emulatorcheck.MainActivity.onCreate(MainActivity.java:149)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
at android.security.keystore.KeymasterUtils.addUserAuthArgs(KeymasterUtils.java:115)
at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:234)
at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi$AES.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:53)
at javax.crypto.KeyGenerator.init(KeyGenerator.java:189)
at com.cts.emulatorcheck.MainActivity.createKey(MainActivity.java:289)
at com.cts.emulatorcheck.MainActivity.onCreate(MainActivity.java:149)
at android.app.Activity.performCreate(Activity.java:6237)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
@thagikura I also have the issue with the app throwing the:
java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
Every time I start the emulator. Where is the relevant emulator issue, can you send a url so we can track it and comment?
Hmm, @yewrajesh @xawit I tried the latest emulator and it worked without the issue.
What is your emulator's build number?
Mine was sdk_google_phone_x86_64-userdebug 6.0 MASTER 2872745 test-keys
@xawit also the issue I filed was a internal one. Filed on February, once I confirm it's still reproducible with the latest emulator, I'll file another one.
I just updated the SDK tools to 25.2.0 (RC2), emulator version: 25.2.0-3037468, previously 25.1.7.
SDK build tools are at 23.0.3. The emulator image is Nexus_6P_API_23.
So when you set up fingerprints on a fresh emulator instance, you have to set up a lock screen unlock, I set it to 1111 PIN. When you close the emulator, start the application from Android Studio, first the lock screen appears and I can already see in the console that I got the exception.
This time I checked out a fresh sample of asymmetricfingerprintdialog, to check if it's the same, And it is:
Caused by: java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
at android.security.keystore.KeymasterUtils.addUserAuthArgs(KeymasterUtils.java:115)
at android.security.keystore.AndroidKeyStoreKeyPairGeneratorSpi.initialize(AndroidKeyStoreKeyPairGeneratorSpi.java:335)
at java.security.KeyPairGenerator$KeyPairGeneratorImpl.initialize(KeyPairGenerator.java:284)
at java.security.KeyPairGenerator.initialize(KeyPairGenerator.java:192)
at com.example.android.asymmetricfingerprintdialog.MainActivity.createKeyPair(MainActivity.java:183)
at com.example.android.asymmetricfingerprintdialog.MainActivity.onCreate(MainActivity.java:93)
at android.app.Activity.performCreate(Activity.java:6237)
There is also a problem with the emulator, that the first time you type in the pin, you get an error "you have incorrecly typed your PIN 1 times..". The second time, when you push the same number 1111 on the screen you get logged in. But still, when you start the app again in the Android Studio, you get the exception. So the solution is to go to:
Settings -> Security -> Fingerprint -> (confirm PIN) -> add/modify a fingerprint, I had finger 1 and 2 registered, I added finger 3, started the app, and it worked without casting an exception.
Is there something wrong with the keystore? Should the bug be filed here? https://code.google.com/p/android/issues/entry?template=Android%20Emulator%20Bug
@thagikura I'm working on a Mac 10.11.5 with Intel Core i7 processor, the image I'm using is a x86_64 version, if that is of any significance.
The application starts normally if no fingerprints are registered, when restarting the emulator (whole qemu). The exception is only thrown when there were fingerprints stored in security settings before restarting the emulator. A keystore problem, each restart has a different access key to the encrypted fingerprints?
@xawit Thanks for the detailed report.
I believe it's highly likely an issue with the emulator, not on the Keystore.
Could you file the bug on the issue tracker? I tried it on Mac, and the issue was reproducible (not reproducible on Linux).
And unfortunately, the fingerprints with an emulator is flaky, if it's possible I highly recommend you to try a physical device. Sorry for the inconvenience.
Whenever I run into this exception I just go into Settings and add a new fingerprint (even if there is already one there) and then after redeploying the app it works fine for awhile. Perhaps until I restart the emulator. I never figured out what exactly triggers the issue.
We have this issue on devices:
- UMI TOUCH
- ZTE BLADE V7 LITE
still happening for me :
emulator :
nexus 5x, api 23, x86 image
laptop :
mac
Hi Everyone,
I am new to Fingerprint scanner application. I am using Nexus 6 but getting this error. Please look into this and help me.
com.jessicathornsby.fingerprintauthentication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.jessicathornsby.fingerprintauthentication, PID: 31232
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.jessicathornsby.fingerprintauthentication/com.jessicathornsby.fingerprintauthentication.MainActivity}: java.lang.RuntimeException: Failed to init Cipher
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.lang.RuntimeException: Failed to init Cipher
at com.jessicathornsby.fingerprintauthentication.MainActivity.initCipher(MainActivity.java:158)
at com.jessicathornsby.fingerprintauthentication.MainActivity.onCreate(MainActivity.java:88)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: java.security.InvalidKeyException: Unsupported key: null
at android.security.keystore.AndroidKeyStoreUnauthenticatedAESCipherSpi.initKey(AndroidKeyStoreUnauthenticatedAESCipherSpi.java:128)
at android.security.keystore.AndroidKeyStoreCipherSpiBase.init(AndroidKeyStoreCipherSpiBase.java:169)
at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:105)
at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:612)
at javax.crypto.Cipher.tryCombinations(Cipher.java:532)
at javax.crypto.Cipher.getSpi(Cipher.java:437)
at javax.crypto.Cipher.init(Cipher.java:815)
at javax.crypto.Cipher.init(Cipher.java:774)
at com.jessicathornsby.fingerprintauthentication.MainActivity.initCipher(MainActivity.java:151)
at com.jessicathornsby.fingerprintauthentication.MainActivity.onCreate(MainActivity.java:88)
at android.app.Activity.performCreate(Activity.java:6251)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
When running on
Samsung S5 - SM-G800H (Android 6.0.1 API 23). (Fingerprint registered and screen lock is on)
Caused by: java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
at android.security.keystore.KeymasterUtils.addUserAuthArgs(KeymasterUtils.java:115)
at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:234)
at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi$AES.engineInit(AndroidKeyStoreKeyGeneratorSpi.java:53)
at javax.crypto.KeyGenerator.init(KeyGenerator.java:189)
at com.example.android.fingerprintdialog.MainActivity.createKey(MainActivity.java:259)
at com.example.android.fingerprintdialog.MainActivity.onCreate(MainActivity.java:145)
at android.app.Activity.performCreate(Activity.java:6904)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1136)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3266)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3415)
at android.app.ActivityThread.access$1100(ActivityThread.java:229)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1821)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:7331)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Happening also in OnePlus physical devices with Android 6.0.1 Api 23.
@zolbayars AFAIK Samsung uses it's own SDK called Pass and not all of their devices (specially the older ones like the S5 since it didn't come with Android M from factory) have compatibility with the native fingerprint API.
@thagikura Issue is still seen in Samsung Galaxy Note8/Xiaomi MI5S/Xperia Xz running 7.1.1.
Issue has been occurred on Samsung SM-G900F (Android 6.0.1, API 23)
java.lang.IllegalStateException: At least one fingerprint must be enrolled to create keys requiring user authentication for every use
http://crashes.to/s/d5e119037fa
private void showFingerprintDialog() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (FingerprintHelper.canUseFingerprint(this, false)) {
mFingerprintDialog = FingerprintView.Companion.showDialog(this, getFingerprintCallback(), false);
}
}
}
Before showing fingerprint dialog is called:
@RequiresApi(api = Build.VERSION_CODES.M)
public static boolean canUseFingerprint(@NonNull Context context, boolean justHardwareCheck) {
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(KEYGUARD_SERVICE);
FingerprintManager fingerprintManager = (FingerprintManager) context.getSystemService(FINGERPRINT_SERVICE);
if (!fingerprintManager.isHardwareDetected()) {
// return false for samsung shitty devices: https://stackoverflow.com/q/37935959/4024146
return false;
}
if (!justHardwareCheck) {
// this is user option, can change in settings, so we can provide fingerprint authentication when he want...
if (!keyguardManager.isKeyguardSecure()) {
HANDLER.post(() -> Toast.makeText(context, R.string.fingerprint_enable_phone_security, Toast.LENGTH_LONG).show());
return false;
}
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) {
HANDLER.post(() -> Toast.makeText(context, R.string.fingerprint_permission, Toast.LENGTH_LONG).show());
return false;
}
if (!fingerprintManager.hasEnrolledFingerprints()) {
// This happens when no fingerprints are registered.
HANDLER.post(() -> Toast.makeText(context, R.string.fingerprint_register_one_finger, Toast.LENGTH_LONG).show());
return false;
}
}
return true;
}
which must for this users return true
otherwise they can't show dialog, so checking fingerprintManager.hasEnrolledFingerprints()
didn't work for some cases and devices!
jvixux
vjxua'
also seeing this issue on a Galaxy S7 running Android 8.0