It turns out that I had a tiny typo in the url of the service which my ViewModel called its function to do remote fetch. Once it is fixed, there's no crash.
Where is a good place to call ViewModel method after Microsoft Graph successfully gets user info
I followed this link to create my Android app: https://learn.microsoft.com/en-us/graph/tutorials/android
In my app, I only used the SSO authentication methods from this tutorial to sign user in and then get user info. Once I got the user's info, I need to use that info to call ViewModel's method. But that caused crash. I think the reason is that the getting user method returns CompletableFuture. If it is Task, it should work. My intention was to call ViewModel's method inside the thenAccept closure of the CompletableFuture. If I cannot, I don't know any other way to get the user info into the ViewModel's method. The content of ViewModel's method is in viewModelScope.launch { }
The error I got is:
java.lang.IllegalStateException: Job StandaloneCoroutine is already complete or completing, but is being completed with CompletedExceptionally[java.lang.NoClassDefFoundError: kotlinx.coroutines.CoroutineExceptionHandlerImplKt]
Any help is greatly appreciated