xamarin / AndroidX

AndroidX bindings for .NET for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] `androidx.credentials` null Exception

Kebechet opened this issue · comments

Android application type

net8.0-android

Affected platform version

VS 17.8.6 - .NET 8.0.101

Description

I am trying to wrap androidx.credentials into separate nuget to simplify the usage but in methods
_credentialManager.ClearCredentialState or _credentialManager.ClearCredentialStateAsync I get a runtime exception:

[CredManProvService] In CredentialProviderFrameworkImpl onClearCredential
[Binder] Caught a RuntimeException from the binder stub implementation.
[Binder] java.lang.NullPointerException: Parameter specified as non-null is null: method androidx.credentials.CredentialProviderFrameworkImpl$onClearCredential$outcome$1.onResult, parameter response
[Binder] 	at androidx.credentials.CredentialProviderFrameworkImpl$onClearCredential$outcome$1.onResult(Unknown Source:3)
[Binder] 	at androidx.credentials.CredentialProviderFrameworkImpl$onClearCredential$outcome$1.onResult(CredentialProviderFrameworkImpl.kt:367)
[Binder] 	at android.credentials.CredentialManager$ClearCredentialStateTransport.onSuccess(CredentialManager.java:775)
[Binder] 	at android.credentials.IClearCredentialStateCallback$Stub.onTransact(IClearCredentialStateCallback.java:95)
[Binder] 	at android.os.Binder.execTransactInternal(Binder.java:1363)
[Binder] 	at android.os.Binder.execTransact(Binder.java:1304)

Is it problem in my code or it is possible that there is something with the binding ?

Then there is another issue regarding the use of context. Any tips ?
https://stackoverflow.com/questions/77936004/maui-android-credentialmanager-context-problem

  • EDIT: This 2nd issue was resolved with the use of Platform.CurrentActivity

Steps to Reproduce

  1. Download my repo: https://github.com/Kebechet/Maui.CredentialManagers
  2. register service: CredentialManagerAndroidService
  3. Try to call ClearCredentialState (same problem with the commented variant using ClearCredentialStateAsync)

Did you find any workaround?

Nope

he runtime exception you are encountering, java.lang.NullPointerException, suggests that a parameter specified as non-null is actually null during the execution of the method onResult in the CredentialProviderFrameworkImpl$onClearCredential$outcome$1 class.

To resolve this issue, you need to investigate why the parameter response is null when it is expected to be non-null. Here are some steps you can take to debug and resolve the issue:

Check Parameter Initialization: Ensure that any parameters being passed to the onResult method are properly initialized before calling the method.

Review Callback Implementation: Review the implementation of the onResult method in the CredentialProviderFrameworkImpl$onClearCredential$outcome$1 class. Verify that it handles all possible scenarios and does not assume that the response parameter will always be non-null.

Check Caller Code: Review the code where you invoke the _credentialManager.ClearCredentialState or _credentialManager.ClearCredentialStateAsync methods. Make sure that you are handling the response properly and that it is not null before passing it to any callback methods.

Check AndroidX Credentials Library Version: Ensure that you are using the latest version of the AndroidX Credentials library. Sometimes, issues like this are resolved in newer library versions.

Check Documentation and Community Forums: Review the documentation for the AndroidX Credentials library and check community forums or issue trackers for any known issues or solutions related to the onResult method and the ClearCredentialState functionality.

By following these steps and debugging the code systematically, you should be able to identify the root cause of the NullPointerException and implement the necessary fixes to resolve the runtime exception.

Seems to be a problem in the original library:
https://issuetracker.google.com/issues/314926460?pli=1

The call ClearCredentialStateAsync doesnt work on Google Pixel 6(v34) but it works on Samsung S9(v29)

Closing as this seems to be an issue in the underlying Google AndroidX Java package.

@jpobst shouldnt this be kept open unit new version of the package fixing the problem is released ?
Because it requires you to create update for androidx.credentials containing the bug fix.

When the new Java version is released, our process will automatically find it and bind the new version as part of the regular periodic updates process. So there's nothing additional that we need to do to fix this issue.

Perfect, thank you