app crashes on getAccounts()
See original GitHub issueI am following the sample app to try and get silent login, but my app crashes on the getAccounts() function. if i clear the app storage no crash but if there is a previous login it crashes with the following stack trace
* Attempt to get a user and acquireTokenSilent
* If this fails we do an interactive request
*/
List<IAccount> accounts = null;
try {
accounts = myApp.getAccounts(); //crashes here
if (accounts != null && accounts.size() == 1) {
/* We have 1 account */
...
}...
java.lang.RuntimeException: Unable to resume activity {jbloomfield.macroapp/jbloomfield.macroapp.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3822)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3854)
at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:51)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:145)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6718)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:859)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
at com.microsoft.identity.common.internal.cache.AccountCredentialCache.getAccountsWithKeys(AccountCredentialCache.java:168)
at com.microsoft.identity.common.internal.cache.AccountCredentialCache.getAccounts(AccountCredentialCache.java:184)
at com.microsoft.identity.common.internal.cache.AccountCredentialCache.getAccountsFilteredBy(AccountCredentialCache.java:205)
at com.microsoft.identity.common.internal.cache.MsalOAuth2TokenCache.getAccounts(MsalOAuth2TokenCache.java:337)
at com.microsoft.identity.client.PublicClientApplication.getAccounts(PublicClientApplication.java:330)
at jbloomfield.macroapp.AuthManager.getAccs(AuthManager.java:124)
at jbloomfield.macroapp.MainActivity.onResume(MainActivity.java:129)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1413)
at android.app.Activity.performResume(Activity.java:7301)
Issue Analytics
- State:
- Created 5 years ago
- Comments:21 (8 by maintainers)
Top Results From Across the Web
java - Calling any of AccountManager getAccounts makes my ...
Just a single activity and creating an instance of AccountManger then calling getAccounts() and it never reaches the for (... line.
Read more >App crashes on one specific account - Microsoft Community
Hi,. I have downloaded an app and it crashes every time I open it. So I created a new account and guess what,...
Read more >Demo Website
This screen is visible only in development. It will not appear if the app crashes in production. Open your browser's developer console to...
Read more >Order SDK changes? App crashing with didn't find class "com ...
Order SDK changes? App crashing with didn't find class "com.clover.sdk.v3.order.Order". Have there been any recent changes to the orders SDK?
Read more >Identifying the cause of common crashes - Apple Developer
You can identify the causes for many app crashes by looking for specific patterns in the crash report and taking specific diagnostic actions...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey guys, I’ve implemented a workaround for this issue, I’m just catching the exception and when that happens I:
I know that this is a super hacky solution, but It’s the only workaround that I’ve been able to find so far. If any of you can confirm that this fixes the issue for you as well, that would be super useful for me.
Thanks!
The issue is still present on msal 0.2.2
@4gus71n : ty for your workaround