mjwheatley / cordova-plugin-android-fingerprint-auth

A cordova plugin for fingerprint authentication using the hardware fingerprint scanner on devices running Android 6+
Apache License 2.0
169 stars 131 forks source link

android.content.res.Resources$NotFoundException #136

Open alexandrefelipemuller opened 4 years ago

alexandrefelipemuller commented 4 years ago

Hi guys, I'm using cordova finger print auth plugin version 1.5, and my App is showing being crashed on Firebase crashanalytics like this one: java.lang.RuntimeException: Unable to start activity ComponentInfo{.....}: android.content.res.Resources$NotFoundException: Resource ID #0x0 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0 at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:190) at android.content.res.Resources.loadXmlResourceParser(Resources.java:2101) at android.content.res.Resources.getLayout(Resources.java:1115) at android.view.LayoutInflater.inflate(LayoutInflater.java:424) at com.cordova.plugin.android.fingerprintauth.FingerprintAuthenticationDialogFragment.onCreateView(FingerprintAuthenticationDialogFragment.java:85) at android.app.Fragment.performCreateView(Fragment.java:2353) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:995) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1171) at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1153) at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:2039) at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:176) at android.app.Activity.performCreateCommon(Activity.java:6673) at android.app.Activity.performCreate(Activity.java:6681) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618) ... 9 more This crash seens to be related to app being put in background during auth. This is top 1 crash on the list and far from second. Making a search on the web I found the correction being discussed on a fork : https://github.com/mjwheatley/cordova-plugin-android-fingerprint-auth/issues/52

FingerprintAuthenticationDialogFragment.java

@Override public void onPause() { super.onPause(); // Dismiss dialog to avoid doubling it on resume if app was closed by OS dismissAllowingStateLoss(); mFingerprintUiHelper.stopListening(); }

Can you please check if this correction can be applied on your plugin too?

mjwheatley commented 4 years ago

I would question if this should be done automatically or not. Can you think of any scenarios where you would not want the dialog to be dismissed? Currently management of the dialog and app lifecycle management is in the hands of the developer. A DISMISS action has been provided to dismiss the dialogue as needed. The developer can implement this onPause() functionality as needed from the web app code.

alexandrefelipemuller commented 4 years ago

oh.. do you say like, handle pause event on cordova and call plugin dissmiss method? yeah maybe this can do the trick

mibrito707 commented 4 years ago

Hello guys, I also had this problem and after a quick search I found the real problem and steps to reproduce it here: https://github.com/NiklasMerz/cordova-plugin-fingerprint-aio/issues/158 and while calling the dismiss() method can be a solution, I found it to be an overkilling because I don't always want to close the Fingerprint dialog while in the background since most of the time it just works, ideally we should handle the error when occurs (and that is not always the case and not for all users/devices). For that reason we implemented our own solution and opened a PR on this repo, please consider it as a solution and merge if possible. https://github.com/mjwheatley/cordova-plugin-android-fingerprint-auth/pull/139 PD: I also found a faster and consistent way of reproduce the issue in case you wanna use it for testing: Enable developer options on your phone or emulator, go to the Developers options screen and in the Apps section click on Background process limit to select either a small number or No background processes. Now open the Mobile app and the Fingerprint dialog, then switch to another app without closing it, when you return again to the app, you'll see the crash message.

mcendon commented 4 years ago

https://github.com/mjwheatley/cordova-plugin-android-fingerprint-auth/issues/140#issuecomment-597386330