has anyone faced this exception before when attemp...
# multiplatform
o
has anyone faced this exception before when attempting to run on iOS? https://medium.com/@liwp.stephen/fix-kotlin-native-incorrectdereferenceexception-issue-on-kmm-project-71745c11d9a3 It isn’t clear where this solution should be placed, but the genius who posted this has also encountered the error
j
This looks like something that happened before use of new Kotlin Native memory model?
o
hmmm…no idea what the new Kotlin Native memory model is, I am following this tutorial https://play.kotlinlang.org/hands-on/Networking%20and%20Data%20Storage%20with%20Kotlin%20Multiplatfrom%20Mobile/01_Introduction
does it have this new memory model you’re talking about?
ah it comes just by virtue of using 1.7.20?
j
Yes, it should be enabled by default in 1.7.20....are you still seeing that error when using that version?
o
let me check, issue with KMM is that there’s a combo of versions that you have to have nailed down for it to compile or else everything will be complaining
heyy..it does work
thanks @John O'Reilly!
you know this block inside the project’s build.gradle?
Copy code
plugins {
    //trick: for the same plugin versions in all sub-modules
    id("com.android.application").version("7.3.0").apply(false)
    id("com.android.library").version("7.3.0").apply(false)
    kotlin("android").version("1.7.20").apply(false)
    kotlin("multiplatform").version("1.7.20").apply(false)
}
do you know how I can abstract away the version number and be able to pass it to
version()
? it takes a Provider, but that’s an interface, and I am not sure where I could find an impl of that as an example
takes a Provider from
org.gradle.api.provider
e
you can use the gradle version catalog instead,
Copy code
// gradle/libs.versions.toml
[versions]
android-gradle = "7.3.0"
[plugins]
android-application = { id = "com.android.application", version.ref = "android-gradle" }

// build.gradle.kts
plugins {
    alias(libs.plugins.android.application) apply false
etc.
or set plugin versions uniformly in
settings.gradle.kts
,
Copy code
pluginManagement {
    plugins {
        resolutionStrategy {
            eachPlugin {
                if (requested.id.id.startsWith("com.android.")) useVersion("7.3.0")