kokoichi206 / android-app

0 stars 0 forks source link

KMM #13

Open kokoichi206 opened 1 year ago

kokoichi206 commented 1 year ago
Screen Shot 2022-09-19 at 20 44 10
kokoichi206 commented 1 year ago

shared モジュールの API を iOS から呼んだ時にエラー

Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared <object>@82e625e8 from other thread

https://www.apollographql.com/blog/mobile/kotlin/whats-new-with-multiplatform-in-apollo-kotlin/

次の2行を gradle.properties に追加する。

kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false

また、build.gradle に以下を追加する。

// Workaround for https://youtrack.jetbrains.com/issue/KT-51970
afterEvaluate {
    afterEvaluate {
        tasks.configureEach {
            if (
                name.startsWith("compile")
                && name.endsWith("KotlinMetadata")
            ) {
                enabled = false
            }
        }
    }
}

むじ〜〜

いや、なんかよくわからんけど、ktor のバージョンを 2.1.0 -> 2.0.0 にしたら解決した。。。

2.1.0 と 2.0.0 を変えて試したら変わったので、ここが原因の一部っぽい!