AzureAD / microsoft-authentication-library-for-android

Microsoft Authentication Library (MSAL) for Android
http://aka.ms/aadv2
MIT License
216 stars 124 forks source link

MSAL Null Pointer Exception occurred when start authentication flow on S9+ Devices #602

Closed wylzt8384 closed 2 years ago

wylzt8384 commented 5 years ago

When Attempt to using MSAL acquireToken method, the flow always end up with NullPointerException, please check below. Attempt to invoke virtual method 'ar ao.a(an)' on a null object reference :android.support.customtabs.CustomTabsSession newSession(android.support.customtabs.CustomTabsCallback)

seems it is like a ChromeTab usage problem.

Notes: If we select to ‘always use Chrome’ as the default browser for any URL access in another App, the problem disappear. That’s, the problem happens in the scenario of the S9+ default browser.

wangyeking commented 5 years ago

add more detailed traces.

Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.support.customtabs.CustomTabsSession android.support.customtabs.CustomTabsClient.newSession(android.support.customtabs.CustomTabsCallback)' on a null object reference
at com.microsoft.identity.common.internal.ui.browser.CustomTabsManager.bind(CustomTabsManager.java:108)
at com.microsoft.identity.common.internal.ui.browser.BrowserAuthorizationStrategy.requestAuthorization(BrowserAuthorizationStrategy.java:79)
at com.microsoft.identity.common.internal.providers.oauth2.OAuth2Strategy.requestAuthorization(OAuth2Strategy.java:93)
at com.microsoft.identity.client.internal.controllers.LocalMSALController.performAuthorizationRequest(LocalMSALController.java:124)
at com.microsoft.identity.client.internal.controllers.LocalMSALController.acquireToken(LocalMSALController.java:99)
at com.microsoft.identity.client.internal.controllers.MSALInteractiveTokenCommand.execute(MSALInteractiveTokenCommand.java:60)
at com.microsoft.identity.client.internal.controllers.MSALApiDispatcher$1.run(MSALApiDispatcher.java:70)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)
iambmelt commented 5 years ago

Thank you for providing the trace information and reporting this issue; we'll prioritize and investigate accordingly.

joshfriend commented 5 years ago

I created a brand new Nougat (API 24) emulator to test out an unrelated crash and got a crash with this stacktrace:

E/LoginActivity$authenticationCallback: Authentication error
    com.microsoft.identity.client.exception.MsalClientException: Attempt to invoke virtual method 'androidx.browser.customtabs.CustomTabsSession androidx.browser.customtabs.CustomTabsClient.newSession(androidx.browser.customtabs.CustomTabsCallback)' on a null object reference
        at com.microsoft.identity.client.internal.controllers.ExceptionAdapter.msalExceptionFromException(ExceptionAdapter.java:108)
        at com.microsoft.identity.client.internal.controllers.MSALApiDispatcher$1.run(MSALApiDispatcher.java:81)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
        at java.lang.Thread.run(Thread.java:761)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'androidx.browser.customtabs.CustomTabsSession androidx.browser.customtabs.CustomTabsClient.newSession(androidx.browser.customtabs.CustomTabsCallback)' on a null object reference
        at com.microsoft.identity.common.internal.ui.browser.CustomTabsManager.bind(CustomTabsManager.java:108)
        at com.microsoft.identity.common.internal.ui.browser.BrowserAuthorizationStrategy.requestAuthorization(BrowserAuthorizationStrategy.java:79)
        at com.microsoft.identity.common.internal.providers.oauth2.OAuth2Strategy.requestAuthorization(OAuth2Strategy.java:93)
        at com.microsoft.identity.client.internal.controllers.LocalMSALController.performAuthorizationRequest(LocalMSALController.java:124)
        at com.microsoft.identity.client.internal.controllers.LocalMSALController.acquireToken(LocalMSALController.java:99)
        at com.microsoft.identity.client.internal.controllers.MSALInteractiveTokenCommand.execute(MSALInteractiveTokenCommand.java:60)
        at com.microsoft.identity.client.internal.controllers.MSALApiDispatcher$1.run(MSALApiDispatcher.java:70)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) 
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607) 
        at java.lang.Thread.run(Thread.java:761) 

Currently using v0.2.2 of the library

heidijinxujia commented 5 years ago

@joshfriend do you still encounter this issue with the latest version?

harry2845 commented 5 years ago

@heidijinxujia I have met the same problem today with 0.2.2 version. Using Samsung Note 9 with Android P.

joshfriend commented 5 years ago

I have not been able to upgrade to the v0.3.1-alpha tag because of the large amount of breaking api changes. I'm also holding off on updating until the synchronous APIs are available.

iambmelt commented 4 years ago

Assigning @shahzaibj -- if you have capacity, can you examine the v1.0.0 for bugs here and close if this doesn't appear to be an issue or repro?