iamMehedi / Secured-Preference-Store

A cryptography library and a SharedPreferences wrapper for Android that encrypts the content with 256 bit AES encryption. The Encryption key is securely stored in device's KeyStore.
562 stars 97 forks source link

KeyStoreService.del null object reference on HUAWEI device 7.0 #25

Open Gaetano-Dati opened 6 years ago

Gaetano-Dati commented 6 years ago

java.lang.RuntimeException: Unable to create application com.bananasrl.banana.Utils.App: java.lang.NullPointerException: Attempt to invoke interface method 'int android.security.IKeystoreService.del(java.lang.String, int)' on a null object reference at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5678) at android.app.ActivityThread.-wrap2(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1637) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:156) at android.app.ActivityThread.main(ActivityThread.java:6524) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:941) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:831) Caused by: 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 devliving.online.securedpreferencestore.EncryptionManager.generateAESKey(EncryptionManager.java:502) at devliving.online.securedpreferencestore.EncryptionManager.generateKey(EncryptionManager.java:472) at devliving.online.securedpreferencestore.EncryptionManager.setup(EncryptionManager.java:145) at devliving.online.securedpreferencestore.EncryptionManager.(EncryptionManager.java:124) at devliving.online.securedpreferencestore.SecuredPreferenceStore.(SecuredPreferenceStore.java:42) at devliving.online.securedpreferencestore.SecuredPreferenceStore.init(SecuredPreferenceStore.java:87) at com.bananasrl.banana.Utils.App.onCreate(App.java:111) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1028) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5659) ... 8 more

Gaetano-Dati commented 6 years ago

@iamMehedi please can you tell me something about It? Thanks

iamMehedi commented 6 years ago

Huawei devices are encountering a few issues and most probably that has to do something with the device's keystore implementation. I'll take a closer look at this tomorrow and let you know if I can find anything.

On Feb 1, 2018 12:08 AM, "Dati Gaetano" notifications@github.com wrote:

@iamMehedi https://github.com/iammehedi please can you tell me something about It? Thanks

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/iamMehedi/Secured-Preference-Store/issues/25#issuecomment-362019752, or mute the thread https://github.com/notifications/unsubscribe-auth/ADhUc0nD30xHhZmIh5-pfHgklb39919-ks5tQKwNgaJpZM4RxwdN .

Gaetano-Dati commented 6 years ago

Ok, the client is waiting for my Application which also contains your library. Thank you very much.

iamMehedi commented 6 years ago

@Gaetano-Dati the error is happening in internal code of the KeyGenerator

Gaetano-Dati commented 6 years ago

And how can I delete this error? Modify something into the KeyGenerator class? Can you do it and publish new version? I'm about to publish the application. Thanks

iamMehedi commented 6 years ago

It's an internal issue of android/huawei's Keystore implementation, so there's nothing to fix in the library in particular.

Gaetano-Dati commented 6 years ago

Uhmm so the crash remains? And we can't deal with it? Ok. Thanks

Gaetano-Dati commented 6 years ago

I'm afraid that this problem will happen on every Huawei device.

iamMehedi commented 6 years ago

As the issue seems to be with the OS on Huawei devices, this will happen on all their devices at least the ones that are running the same version of the OS.

javichaques commented 6 years ago

Hello,

I have the same issue in my Huawei P8 Lite.

@Gaetano-Dati @iamMehedi Were you able to solve this? Workaround?

Gaetano-Dati commented 6 years ago

No, sorry. I'm still waiting for a solution

Il gio 31 mag 2018, 17:40 Javi Chaqués notifications@github.com ha scritto:

Hello,

I have the same issue in my Huawei P8 Lite.

@Gaetano-Dati https://github.com/Gaetano-Dati @iamMehedi https://github.com/iamMehedi Were you able to solve this? Workaround?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/iamMehedi/Secured-Preference-Store/issues/25#issuecomment-393573643, or mute the thread https://github.com/notifications/unsubscribe-auth/AWYtkfunhabuKqg2fK_FYFgNraX-ikpJks5t4A7YgaJpZM4RxwdN .

javichaques commented 6 years ago

:( How are you save the preference ins this moment? @Gaetano-Dati

Thank you

maxkomarychev commented 6 years ago

@Gaetano-Dati hey, did you get this error on actual device you have or it's from google pre-launch report or any other crash-reporting service (like crashlytics..)?

if first is true - did you by any chance tried this on any other android version on Huawei device?

kutran commented 6 years ago

I just saw this on our pre-launch report trying to start an internal test track. I am wondering running this will cause the same problem on Huawei (or any other phones like ZTE).

I think FireBase has Android Testing on the cloud; I am going to try it out.

xrom888 commented 6 years ago

I tried last version 0.7.0 on my Huawei P7 works well now.