https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
t

tylerwilson

06/03/2021, 1:14 PM
Okay, so I moved up to Kotlin 1.5.10 (now that Compose beta8 supports it) and I am now getting exceptions on iOS in my common code in what was working network code. I do something like this:
Copy code
GlobalScope.apply {
            launch(ApplicationDispatcher) {
                try {
                    val result: String = client.get {
I know that GlobalScope is now a ‘delicate’ API. What is the preferred/canonical/best way to launch network calls in common code now? Thanks!
You know what would be handy? A way to have the Android/JVM side have a switch to have it behave like the iOS (freezing objects and the like) so that we can debug these issues in Android Studio…
s

Sam

06/03/2021, 1:27 PM
Are you getting a concurrent modification exception in your tests? I was struggling with that last night. It’s an issue with kotlinx serialization.
t

tylerwilson

06/03/2021, 1:28 PM
Copy code
"mutation attempt of frozen kotlin.collections.HashMap@2b05c28"
did you find a fix?
s

Sam

06/03/2021, 1:32 PM
Yes. One fix was to add @ThreadLocal to your global json config. That didn’t work for me but another suggestion did. I’m not in front of my computer right now but it was to add an option to the json config to disallow alternate names or something similar. I’ll follow up in a bit when I get there.
It’s an open issue in the GitHub repo if you want to look for it.
t

tylerwilson

06/03/2021, 1:33 PM
thank you, it would be much appreciated. i understand progress, but a little frustrating when it worked the day before. 🙂
a

Ankit Dubey

06/03/2021, 1:36 PM
shared module allows only few APIs in its gradle file. I wish I can add this androidx.lifecycle:lifecycle-runtime-ktx dependency. but sadly using GlobalScope Hope we’ll get better option
s

Sam

06/03/2021, 1:42 PM
Here’s the line I added to my json config that fixed the issue for me. FWIW, the issue is fixed in 1.2.2 but that isn’t out yet.
Copy code
useAlternativeNames = false
t

tylerwilson

06/03/2021, 1:43 PM
checking.
Awesome!! Got past the issue, thank you! Now just my own server error. :-)
🎉 1
3 Views