question

WeiWen-3421 avatar image
0 Votes"
WeiWen-3421 asked WeiWen-3421 answered

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://docs.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

microsoft-graph-sdk
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I actually put the ViewModel's method call in runOnUiThread closure which is inside the thenAccept closure. I did this because I already have some other code that need to run inside runOnUiThread.

If I don't put it inside runOnUiThread, I got this error:

java.lang.NoClassDefFoundError: kotlinx.coroutines.CoroutineExceptionHandlerImplKt
Caused by: java.lang.ExceptionInInitializerError
Caused by: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes

0 Votes 0 ·

1 Answer

WeiWen-3421 avatar image
0 Votes"
WeiWen-3421 answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.