E/KeyStore( 6702): generateKeyInternal failed on response -1000
E/SecureStorageAndroid( 6702): StorageCipher initialization failed
E/SecureStorageAndroid( 6702): java.security.ProviderException: Failed to generate key pair
E/SecureStorageAndroid( 6702): at android.security.keystore.AndroidKeyStoreKeyPairGeneratorSpi.generateKeystoreKeyPair(AndroidKeyStoreKeyPairGeneratorSpi.java:515)
E/SecureStorageAndroid( 6702): at android.security.keystore.AndroidKeyStoreKeyPairGeneratorSpi.generateKeyPair(AndroidKeyStoreKeyPairGeneratorSpi.java:471)
E/SecureStorageAndroid( 6702): at java.security.KeyPairGenerator$Delegate.generateKeyPair(KeyPairGenerator.java:727)
E/SecureStorageAndroid( 6702): at com.it_nomads.fluttersecurestorage.ciphers.RSACipher18Implementation.createKeys(RSACipher18Implementation.java:145)
E/SecureStorageAndroid( 6702): at com.it_nomads.fluttersecurestorage.ciphers.RSACipher18Implementation.createRSAKeysIfNeeded(RSACipher18Implementation.java:112)
E/SecureStorageAndroid( 6702): at com.it_nomads.fluttersecurestorage.ciphers.RSACipher18Implementation.<init>(RSACipher18Implementation.java:36)
E/SecureStorageAndroid( 6702): at com.it_nomads.fluttersecurestorage.ciphers.KeyCipherAlgorithm$$ExternalSyntheticLambda0.apply(D8$$SyntheticClass:0)
E/SecureStorageAndroid( 6702): at com.it_nomads.fluttersecurestorage.ciphers.StorageCipherFactory.getSavedStorageCipher(StorageCipherFactory.java:77)
E/SecureStorageAndroid( 6702): at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.initStorageCipher(FlutterSecureStorage.java:185)
E/SecureStorageAndroid( 6702): at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.ensureInitialized(FlutterSecureStorage.java:162)
E/SecureStorageAndroid( 6702): at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.containsKey(FlutterSecureStorage.java:64)
E/SecureStorageAndroid( 6702): at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin$MethodRunner.run(FlutterSecureStoragePlugin.java:147)
E/SecureStorageAndroid( 6702): at android.os.Handler.handleCallback(Handler.java:938)
E/SecureStorageAndroid( 6702): at android.os.Handler.dispatchMessage(Handler.java:99)
E/SecureStorageAndroid( 6702): at android.os.Looper.loop(Looper.java:223)
E/SecureStorageAndroid( 6702): at android.os.HandlerThread.run(HandlerThread.java:67)
E/SecureStorageAndroid( 6702): Caused by: android.security.KeyStoreException: Unknown error
E/SecureStorageAndroid( 6702): at android.security.KeyStore.getKeyStoreException(KeyStore.java:1301)
E/SecureStorageAndroid( 6702): ... 16 more
E/KeyStore( 6702): generateKeyInternal failed on response -1000
E/SecureStorageAndroid( 6702): EncryptedSharedPreferences initialization failed
E/SecureStorageAndroid( 6702): java.security.GeneralSecurityException: Keystore operation failed
E/SecureStorageAndroid( 6702): at androidx.security.crypto.MasterKeys.generateKey(MasterKeys.java:149)
E/SecureStorageAndroid( 6702): at androidx.security.crypto.MasterKeys.getOrCreate(MasterKeys.java:100)
E/SecureStorageAndroid( 6702): at androidx.security.crypto.MasterKey$Builder$Api23Impl.build(MasterKey.java:380)
E/SecureStorageAndroid( 6702): at androidx.security.crypto.MasterKey$Builder.build(MasterKey.java:320)
E/SecureStorageAndroid( 6702): at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.initializeEncryptedSharedPreferencesManager(FlutterSecureStorage.java:247)
E/SecureStorageAndroid( 6702): at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.ensureInitialized(FlutterSecureStorage.java:170)
E/SecureStorageAndroid( 6702): at com.it_nomads.fluttersecurestorage.FlutterSecureStorage.containsKey(FlutterSecureStorage.java:64)
E/SecureStorageAndroid( 6702): at com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin$MethodRunner.run(FlutterSecureStoragePlugin.java:147)
E/SecureStorageAndroid( 6702): at android.os.Handler.handleCallback(Handler.java:938)
E/SecureStorageAndroid( 6702): at android.os.Handler.dispatchMessage(Handler.java:99)
E/SecureStorageAndroid( 6702): at android.os.Looper.loop(Looper.java:223)
E/SecureStorageAndroid( 6702): at android.os.HandlerThread.run(HandlerThread.java:67)
E/SecureStorageAndroid( 6702): Caused by: java.security.ProviderException: Keystore operation failed
E/SecureStorageAndroid( 6702): at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi.engineGenerateKey(AndroidKeyStoreKeyGeneratorSpi.java:331)
E/SecureStorageAndroid( 6702): at javax.crypto.KeyGenerator.generateKey(KeyGenerator.java:612)
E/SecureStorageAndroid( 6702): at androidx.security.crypto.MasterKeys.generateKey(MasterKeys.java:145)
E/SecureStorageAndroid( 6702): ... 11 more
E/SecureStorageAndroid( 6702): Caused by: android.security.KeyStoreException: Unknown error
E/SecureStorageAndroid( 6702): at android.security.KeyStore.getKeyStoreException(KeyStore.java:1301)
E/SecureStorageAndroid( 6702): ... 14 more
Flutter doctor:
[!] Flutter (Channel stable, 3.22.2, on macOS 14.5 23F79 darwin-arm64, locale en-VN)
• Flutter version 3.22.2 on channel stable at /Users/vuitv/fvm/versions/3.22.2
! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/3.2.6/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/vuitv/fvm/versions/3.22.2. Consider adding /Users/vuitv/fvm/versions/3.22.2/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 761747bfc5 (3 months ago), 2024-06-05 22:15:13 +0200
• Engine revision edd8546116
• Dart version 3.4.3
• DevTools version 2.34.3
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/vuitv/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
Hello, I am getting "StorageCipher initialization failed" issue when I run the app.
Running on device Android 11 (api 30): Error Running on device Android 13 (api 33): Ok
Flutter 3.22.2 flutter_secure_storage: ^9.2.2 shared_preferences: ^2.3.2
Flutter doctor: