xamarin-fingerprint icon indicating copy to clipboard operation
xamarin-fingerprint copied to clipboard

Android: Object reference not set to an instance of an object at Plugin.Fingerprint.Dialog.FingerprintDialogFragment.OnResume ()

Open saqibrashed opened this issue 7 years ago • 9 comments

Steps to reproduce

Unable to reproduce the exception on my own.

Expected behavior

There should not be a null reference exception.

Actual behavior

Receiving an exception "Object reference not set to an instance of an object". The stack-trace shows that the exception occurred on "OnResume" method but I don't have any implementation for it. I received this exception in the production environment. Completely unable to reproduce it on my own. Please see the attached crashlog for details.

Crashlog

"Error": { "Data": {}, "ClassName": "System.NullReferenceException", "Message": "Object reference not set to an instance of an object", "StackTrace": [ { "LineNumber": 0, "ClassName": "Plugin.Fingerprint.Dialog.FingerprintDialogFragment", "FileName": "", "MethodName": "OnResume()", "Raw": "at Plugin.Fingerprint.Dialog.FingerprintDialogFragment.OnResume () [0x0004b] in :0" }, { "LineNumber": 0, "ClassName": "Android.App.Fragment", "FileName": "", "MethodName": "n_OnResume(System.IntPtr jnienv, System.IntPtr native__this)", "Raw": "at Android.App.Fragment.n_OnResume (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in :0" }, { "Raw": "at (wrapper dynamic-method) System.Object.cd917958-7f2a-4738-9697-72a244ce32e9(intptr,intptr)" } ] }

Configuration

Version of the Plugin: 1.4.7.0

Platform: Android 8 (API level 26)

Device: Huawei (RNE-L21)

saqibrashed avatar Oct 18 '18 08:10 saqibrashed

Hi @saqibrashed,

I'm the friendly issue checker. Thanks for using the issue template :star2: I appreciate it very much. I'm sure, the maintainers of this repository will answer, soon.

smsissuechecker avatar Oct 18 '18 08:10 smsissuechecker

Hi, for me also getting the same exception App.Xaml.cs: var result = await CrossFingerprint.Current.IsAvailableAsync(true); if (result) { try { var isAuthenticated = await CrossFingerprint.Current.AuthenticateAsync("Unlock App"); if (isAuthenticated.Authenticated) { base.OnStart(); } else { return; } } catch (Exception ex) {

                    throw;
                }
            }

MainActivity.cs: CrossCurrentActivity.Current.Activity = this; CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity);

Permissions:

sylendra7 avatar Oct 22 '18 18:10 sylendra7

Hi, for me also getting the same exception App.Xaml.cs: var result = await CrossFingerprint.Current.IsAvailableAsync(true); if (result) { try { var isAuthenticated = await CrossFingerprint.Current.AuthenticateAsync("Unlock App"); if (isAuthenticated.Authenticated) { base.OnStart(); } else { return; } } catch (Exception ex) {

                throw;
            }
        }

MainActivity.cs: CrossCurrentActivity.Current.Activity = this; CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity);

Permissions:

sylendra7 avatar Oct 22 '18 18:10 sylendra7

I am seeing this with version 1.4.7 as well. Here is the stack trace from HockeyApp.

Xamarin caused by: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object
  at Plugin.Fingerprint.Dialog.FingerprintDialogFragment.OnResume () [0x0004b] in <d1d3ad68d9a3469fb250007565ffc31f>:0 
  at Android.App.Fragment.n_OnResume (System.IntPtr jnienv, System.IntPtr native__this) [0x00009] in <c8349fab7b1c4b3c9b17d8dc0fb8bac4>:0 
  at (wrapper dynamic-method) System.Object.26(intptr,intptr)
	at md5f842b5ac8eb52ac6d95c95091b13caff.FingerprintDialogFragment.n_onResume(Native Method)
	at md5f842b5ac8eb52ac6d95c95091b13caff.FingerprintDialogFragment.onResume(FingerprintDialogFragment.java:44)
	at android.app.Fragment.performResume(Fragment.java:2657)
	at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1319)
	at android.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1549)
	at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1611)
	at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3039)
	at android.app.FragmentManagerImpl.dispatchResume(FragmentManager.java:3001)
	at android.app.FragmentController.dispatchResume(FragmentController.java:200)
	at android.app.Activity.performResume(Activity.java:7107)
	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3690)
	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3755)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2939)
	at android.app.ActivityThread.-wrap11(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1612)
	at android.os.Handler.dispatchMessage(Handler.java:105)
	at android.os.Looper.loop(Looper.java:164)
	at android.app.ActivityThread.main(ActivityThread.java:6710)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)

I can find no pattern to the type of devices affected. It seems to affect all - LG, Samsung, Pixel and runs across multiple OS versions - 8.1, 8.0. 9.0, 7.0, 5.0.

I see release mode for the Android project generates the pdb debug symbols. For future versions if you added MonoSymbolArchive set to true and made the corresponding mSYM that was generated available we could use mono-symbolicate to help track down the exact line number.

roberleitner avatar Nov 13 '18 18:11 roberleitner

Any update on this? I'm getting the same error and is causing a crash. Any input on how to catch the exception and handle it gracefully?

RickB864 avatar Jan 07 '19 16:01 RickB864

Any update on this? I'm getting the same error and is causing a crash. Any input on how to catch the exception and handle it gracefully?

Unfortunately not. I haven't received any update nor have i received any answer from anyone.

saqibrashed avatar Jan 13 '19 13:01 saqibrashed

@saqibrashed @sylendra7 @roberleitner @RickB864

I have fixed this issue in my application by changing this line:

CrossFingerprint.SetCurrentActivityResolver(() => CrossCurrentActivity.Current.Activity);

to this:

CrossFingerprint.SetCurrentActivityResolver(() => this);

jlhernandez1388 avatar May 01 '19 20:05 jlhernandez1388

@jlhernandez1388 Hello, how did you reproduce the crash?

QuackingKahuna avatar Jul 30 '19 07:07 QuackingKahuna

For anyone else looking at this thread, it should be no longer be an issue in v2.0+ - see here and here. Basically the plugin has been changed to use the official AndroidX fingerprint dialog fragment now.

breenbob avatar Aug 07 '20 17:08 breenbob