Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in crash logs #370

Open
adamdport opened this issue Oct 6, 2021 · 6 comments
Open

NullPointerException in crash logs #370

adamdport opened this issue Oct 6, 2021 · 6 comments

Comments

@adamdport
Copy link

Bug report

Description

I haven't had any issues locally but I noticed a nullpointerexecption in my app's crash logs:

java.lang.RuntimeException: 
  at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4869)
  at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4906)
  at android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:52)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:176)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2307)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:246)
  at android.app.ActivityThread.main (ActivityThread.java:8528)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
Caused by: java.lang.RuntimeException: 
  at android.app.ActivityThread.deliverResults (ActivityThread.java:5511)
  at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4856)
Caused by: java.lang.NullPointerException: 
  at de.niklasmerz.cordova.biometric.Fingerprint.lambda$sendError$1$Fingerprint (Fingerprint.java:161)
  at de.niklasmerz.cordova.biometric.-$$Lambda$Fingerprint$HQesV6eLUymiZZSDRXppmLSXqEY.run (Unknown Source:4)
  at android.app.Activity.runOnUiThread (Activity.java:7154)
  at de.niklasmerz.cordova.biometric.Fingerprint.sendError (Fingerprint.java:160)
  at de.niklasmerz.cordova.biometric.Fingerprint.sendError (Fingerprint.java:132)
  at de.niklasmerz.cordova.biometric.Fingerprint.onActivityResult (Fingerprint.java:115)
  at org.apache.cordova.CordovaInterfaceImpl.onActivityResult (CordovaInterfaceImpl.java:159)
  at org.apache.cordova.CordovaActivity.onActivityResult (CordovaActivity.java:368)
  at android.app.Activity.dispatchActivityResult (Activity.java:8550)
  at android.app.ActivityThread.deliverResults (ActivityThread.java:5504)

Environment

"cordova-plugin-fingerprint-aio": "4.0.2",
"cordova-android": "9.1.0",

Android 11 (SDK 30)
Samsung Galaxy A32 5G
Samsung Galaxy A12

Logs

```
java.lang.RuntimeException: 
  at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4869)
  at android.app.ActivityThread.handleResumeActivity (ActivityThread.java:4906)
  at android.app.servertransaction.ResumeActivityItem.execute (ResumeActivityItem.java:52)
  at android.app.servertransaction.TransactionExecutor.executeLifecycleState (TransactionExecutor.java:176)
  at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:97)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2307)
  at android.os.Handler.dispatchMessage (Handler.java:106)
  at android.os.Looper.loop (Looper.java:246)
  at android.app.ActivityThread.main (ActivityThread.java:8528)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
Caused by: java.lang.RuntimeException: 
  at android.app.ActivityThread.deliverResults (ActivityThread.java:5511)
  at android.app.ActivityThread.performResumeActivity (ActivityThread.java:4856)
Caused by: java.lang.NullPointerException: 
  at de.niklasmerz.cordova.biometric.Fingerprint.lambda$sendError$1$Fingerprint (Fingerprint.java:161)
  at de.niklasmerz.cordova.biometric.-$$Lambda$Fingerprint$HQesV6eLUymiZZSDRXppmLSXqEY.run (Unknown Source:4)
  at android.app.Activity.runOnUiThread (Activity.java:7154)
  at de.niklasmerz.cordova.biometric.Fingerprint.sendError (Fingerprint.java:160)
  at de.niklasmerz.cordova.biometric.Fingerprint.sendError (Fingerprint.java:132)
  at de.niklasmerz.cordova.biometric.Fingerprint.onActivityResult (Fingerprint.java:115)
  at org.apache.cordova.CordovaInterfaceImpl.onActivityResult (CordovaInterfaceImpl.java:159)
  at org.apache.cordova.CordovaActivity.onActivityResult (CordovaActivity.java:368)
  at android.app.Activity.dispatchActivityResult (Activity.java:8550)
  at android.app.ActivityThread.deliverResults (ActivityThread.java:5504)
```
@OtherCarlos
Copy link

OtherCarlos commented Mar 23, 2022

Same here. Used to failed with Samsung devices and some Xiaomi another common case is Android 11. I have the same Issue on Production with some users where the App crash when use Fingerprint:

Environment

"cordova-plugin-fingerprint-aio": "^3.0.1",
"cordova-android": "9.1.0",

Android 11 (SDK 30)

  • Redmi Note 9
  • Redmi Note 8
  • POCO X3 Pro
  • Galaxy J7 Prime
  • Galaxy A30

Logs

Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'void org.apache.cordova.CallbackContext.sendPluginResult(org.apache.cordova.PluginResult)' on a null object reference
       at de.niklasmerz.cordova.biometric.Fingerprint.lambda$sendError$1$Fingerprint(Fingerprint.java:117)
       at de.niklasmerz.cordova.biometric.-$$Lambda$Fingerprint$HQesV6eLUymiZZSDRXppmLSXqEY.run(:4)
       at android.app.Activity.runOnUiThread(Activity.java:7153)
       at de.niklasmerz.cordova.biometric.Fingerprint.sendError(Fingerprint.java:116)
       at de.niklasmerz.cordova.biometric.Fingerprint.onActivityResult(Fingerprint.java:89)
       at org.apache.cordova.CordovaInterfaceImpl.onActivityResult(CordovaInterfaceImpl.java:159)
       at org.apache.cordova.CordovaActivity.onActivityResult(CordovaActivity.java:368)
       at android.app.Activity.dispatchActivityResult(Activity.java:8476)
       at android.app.ActivityThread.deliverResults(ActivityThread.java:5132)
       at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4532)
       at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4577)
       at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
       at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
       at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2142)
       at android.os.Handler.dispatchMessage(Handler.java:106)
       at android.os.Looper.loop(Looper.java:236)
       at android.app.ActivityThread.main(ActivityThread.java:7864)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)

@rahulsingh8990
Copy link

I am also facing the same issue, do we have update on this.? @NiklasMerz

@minduch
Copy link

minduch commented Aug 9, 2022

The following changes would probably do good in Fingerprint.java:

public boolean execute(String action, JSONArray args, CallbackContext callbackContext) {
	// Just making sure!
	if (callbackContext == null) {
		Log.v(TAG, "Fingerprint callbackContext is null");
		return FALSE;
	}

	Log.v(TAG, "Fingerprint action: " + action);

	switch(action) {
		case "authenticate":
			executeAuthenticate(args);
			break;

		case "registerBiometricSecret":
			executeRegisterBiometricSecret(args);
			return true;

		case "loadBiometricSecret":
			executeLoadBiometricSecret(args);
			break;

		case "isAvailable":
			executeIsAvailable();
			break;

		default:
			return false;
      }

	return true;
}

private void sendSuccess(Intent intent) {
	Bundle extras;
	if (intent != null && (extras = intent.getExtras()) != null) {
		sendSuccess(extras.getString(PromptInfo.SECRET_EXTRA));
	} else {
		sendSuccess("biometric_success");
	}
}

private void sendError(Intent intent) {
	Bundle extras;
	if (intent != null && (extras = intent.getExtras()) != null) {
		sendError(extras.getInt("code"), extras.getString("message"));
	} else {
		sendError(PluginError.BIOMETRIC_DISMISSED);
	}
}

@minduch
Copy link

minduch commented Aug 9, 2022

I wound't know why the callbackContext is null, but it would certainly avoid the NullPointerExceptionsand be thread-safe.

This was referenced Nov 4, 2022
@bhargavas12
Copy link

bhargavas12 commented Jan 9, 2023

any update on this ? lot of users are facing this issue (app crashes), please let us know if there is any fix/workaround?

@haziqali-2019
Copy link

same issue on samsung devices

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants