martinkasa / capacitor-secure-storage-plugin

Capacitor plugin for storing string values securly on iOS and Android.
MIT License
155 stars 56 forks source link

Resolved NullPointerException causing a blank screen on an ionic app #5

Closed successiveoverrelaxation closed 4 years ago

successiveoverrelaxation commented 4 years ago

The NullPointerException caused a blank and unresponsive screen (after the splash screen) on a Nexus 4 API 27 emulator. This simple change resolved the issue.

successiveoverrelaxation commented 4 years ago

The exception is below: 2019-11-22 16:31:14.884 5609-5703/io.ionic.starter E/Capacitor/Plugin: error java.lang.NullPointerException: Attempt to get length of null array at java.lang.StringFactory.newStringFromBytes(StringFactory.java:209) at com.whitestein.securestorage.SecureStoragePlugin.get(SecureStoragePlugin.java:42) at java.lang.reflect.Method.invoke(Native Method) at com.getcapacitor.PluginHandle.invoke(PluginHandle.java:99) at com.getcapacitor.Bridge$2.run(Bridge.java:526) at android.os.Handler.handleCallback(Handler.java:790) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:164) at android.os.HandlerThread.run(HandlerThread.java:65)

successiveoverrelaxation commented 4 years ago

I was using the SecureStoragePlugin in an authguard and forgot to catch the error for when there is no item. The same code worked on iOS so I thought it was a bug, my mistake.