question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NullPointerException after updating app with msal from 1.4.0 to 1.5.1 and enabled proguard

See original GitHub issue

NullPointerException: Attempt to invoke virtual method ‘java.lang.String com.microsoft.identity.common.internal.dto.AccountRecord.getHomeAccountId()’ on a null object reference

Smartphone

  • Pixel 3 Xl, android 10, WEB VIEW, msal 1.5.1, obfuscation is ON

Stacktrace

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: PID: 22613
    java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.microsoft.identity.common.internal.dto.AccountRecord.getHomeAccountId()' on a null object reference
        at com.microsoft.identity.client.AccountAdapter$HomeAccountFilter.filter(AccountAdapter.java:82)
        at com.microsoft.identity.client.AccountAdapter.filterCacheRecords(AccountAdapter.java:351)
        at com.microsoft.identity.client.AccountAdapter.adapt(AccountAdapter.java:153)
        at com.microsoft.identity.client.SingleAccountPublicClientApplication.getAccountFromICacheRecordList(SingleAccountPublicClientApplication.java:515)
        at com.microsoft.identity.client.SingleAccountPublicClientApplication.getPersistedCurrentAccount(SingleAccountPublicClientApplication.java:479)
        at com.microsoft.identity.client.SingleAccountPublicClientApplication.acquireTokenSilentAsync(SingleAccountPublicClientApplication.java:603)
        at x.a.a.e.q.a$h$a.a(AuthorizationRepository.kt:56)
        at x.a.a.e.q.a$h$a.accept(AuthorizationRepository.kt:29)
        at m.b.i0.d.f.a(ConsumerSingleObserver.java:62)
        at m.b.i0.e.f.m$a.a(SingleDoOnSuccess.java:60)
        at m.b.i0.e.f.b$a.a(SingleCreate.java:67)
        at x.a.a.e.k.a$a$a.onCreated(AzureB2CConfig.kt:44)
        at com.microsoft.identity.client.PublicClientApplication$11.onCreated(PublicClientApplication.java:978)
        at com.microsoft.identity.client.PublicClientApplication$9.onTaskCompleted(PublicClientApplication.java:906)
        at com.microsoft.identity.client.PublicClientApplication$9.onTaskCompleted(PublicClientApplication.java:894)
        at com.microsoft.identity.common.internal.controllers.CommandDispatcher$3.run(CommandDispatcher.java:212)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

To Reproduce

  1. Login into app with msal 1.4.0 (Single mode, webview)
  2. Update msal to 1.5.1
  3. Install app update
  4. run acquireTokenSilentAsync for loginApplication

Expected behavior No crash, success in acquireTokenSilentAsync

Actual Behavior App crashed

Additional context Does not repro on debug build without obfuscation

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
azakharenka1commented, May 25, 2020

@kreedula any updates with it? We could catch this exception and manually logout this user but i don’t really like those solution and don’t want to do it)

0reactions
tanmaymanolkar1commented, Jul 27, 2020

@azakharenka1 I believe you may have found a documentation gap for us. Thank you for that, we will work to correct it and apologies for the inconvenience caused.

The possible reason you may be facing this problem is because B2C registered applications need to be used in conjunction with MultipleAccountPublicClientApplication and not SingleAccountPublicClientApplication.

Attaching the link to the resource for implementation details.

https://docs.microsoft.com/en-us/azure/active-directory/develop/single-multi-account#multiple-account-public-client-application

Please let us know if you encounter similar errors after doing the mentioned fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NullPointerException with proguard - android - Stack Overflow
I'm using Proguard with my apps and I'm getting NullPointerExceptions sent to my Developer Console for random users. When I do a ReTrace,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found