react-native-keychain: Huawei Android 7.0 java.lang.NullPointerException
Thanks for the hard work on this package!
I’m not sure this is an issue with this library, but I wanted to document it in case others are also experiencing it (it looks similar to https://github.com/iamMehedi/Secured-Preference-Store/issues/25).
When uploading our app to the Google Play store, google’s pre-launch report indicates that the app is crashing with a null pointer exception (see stack trace at bottom). On launch our app (abbreviated) calls:
createStoreSecret = () => Keychain
.setGenericPassword('user', 'password')
.then(() => {
// success
})
Keychain
.getGenericPassword()
.then((credentials) => {
if (credentials) {
// success
} else {
createStoreSecret();
}
}).catch(() => {
createStoreSecret();
});
Should we not do this?
Using version 2.0.0-rc of this package.
Environment:
OS: macOS Sierra 10.12.6
Node: 6.9.5
Yarn: Not Found
npm: 3.10.10
Watchman: 4.7.0
Xcode: Xcode 9.1 Build version 9B55
Android Studio: Not Found
Packages: (wanted => installed)
react: 16.0.0
react-native: 0.51.1
Stacktrace:
java.lang.NullPointerException: Attempt to invoke interface method 'int android.security.IKeystoreService.del(java.lang.String, int)' on a null object reference
at android.security.KeyStore.delete(KeyStore.java:186)
at android.security.Credentials.deletePrivateKeyTypeForAlias(Credentials.java:292)
at android.security.Credentials.deleteAllTypesForAlias(Credentials.java:251)
at android.security.keystore.AndroidKeyStoreKeyGeneratorSpi.engineGenerateKey(AndroidKeyStoreKeyGeneratorSpi.java:329)
at javax.crypto.KeyGenerator.generateKey(KeyGenerator.java:580)
at com.oblador.keychain.cipherStorage.CipherStorageKeystoreAESCBC.encrypt(CipherStorageKeystoreAESCBC.java:78)
at com.oblador.keychain.KeychainModule.setGenericPasswordForOptions(KeychainModule.java:65)
at java.lang.reflect.Method.invoke(Native Method)
at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:374)
at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:162)
at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
at android.os.Handler.handleCallback(Handler.java:755)
at android.os.Handler.dispatchMessage(Handler.java:95)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:31)
at android.os.Looper.loop(Looper.java:156)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:194)
at java.lang.Thread.run(Thread.java:776)
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 5
- Comments: 16 (9 by maintainers)
Commits related to this issue
- Catch uncaught exceptions to prevent crash `NullPointerException` thrown on some Huawei devices is crashing entire app. Handle all exceptions and rethrow them as caught exceptions. This is an attemp... — committed to khealth/react-native-keychain by maxkomarychev 6 years ago
- Catch uncaught exceptions to prevent crash `NullPointerException` thrown on some Huawei devices is crashing entire app. Handle all exceptions and rethrow them as caught exceptions. This is an attemp... — committed to maxkomarychev/react-native-keychain by maxkomarychev 6 years ago
- Catch uncaught exceptions to prevent crash (#134) `NullPointerException` thrown on some Huawei devices is crashing entire app. Handle all exceptions and rethrow them as caught exceptions. This is... — committed to oblador/react-native-keychain by maxkomarychev 6 years ago
@maxkomarychev makes sense to me - if we do get an exception in JS we can display the problem to the user and handle appropriately.