Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Desktop Authentication #496

Closed Answered by nbransby
R0BERT10 asked this question in Q&A
Discussion options

I have problem, when I log the user into "FirebaseAuth", and it gives an error in "coroutines".
This happens whenever I run it on desktop, on Android it works normally.

Inside commonMain, App.kt:

fun App() {
 val context = Application().applicationContext
 FirebasePlatform.initializeFirebasePlatform(object : FirebasePlatform() {
 val storage = mutableMapOf<String, String>()
 override fun store(key : String, value : String) = storage.set(key, value)
 override fun retrieve(key : String) = storage[key]
 override fun clear(key : String) { storage.remove(key) }
 override fun log(msg : String) = println(msg)
 })
 val options : FirebaseOptions = FirebaseOptions.Builder()
 .setProjectId("my-projeid")
 .setApiKey("my-apikey")
 .setApplicationId("my-appId")
 .build()
 Firebase.initialize(context, options)
 MaterialTheme{
 val auth = FirebaseAuth.getInstance()
 auth.signInWithEmailAndPassword("teste@fripal.wms", "123456")
 //compose-content
 }
}

Error:
Exception in thread "OkHttp https://securetoken.googleapis.com/..." java.lang.IllegalStateException: Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android' and ensure it has the same version as 'kotlinx-coroutines-core'
at kotlinx.coroutines.internal.MainDispatchersKt.throwMissingMainDispatcherException(MainDispatchers.kt:81)
at kotlinx.coroutines.internal.MissingMainCoroutineDispatcher.missing(MainDispatchers.kt:112)
at kotlinx.coroutines.internal.MissingMainCoroutineDispatcher.isDispatchNeeded(MainDispatchers.kt:96)
at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:319)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:30)
at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default(Cancellable.kt:25)
at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:110)
at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)
at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.setUser(FirebaseAuth.kt:147)
at com.google.firebase.auth.FirebaseAuth.access$setUser(FirebaseAuth.kt:104)
at com.google.firebase.auth.FirebaseAuth$enqueueRefreshTokenCall1ドル.onResponse(FirebaseAuth.kt:332)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:203)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@1dec9e31, Dispatchers.Main[missing]]

You must be logged in to vote

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nbransby
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /