{"id":862,"date":"2021-02-27T20:34:38","date_gmt":"2021-02-27T12:34:38","guid":{"rendered":"https:\/\/woohuiren.me\/blog\/?p=862"},"modified":"2021-02-27T20:40:32","modified_gmt":"2021-02-27T12:40:32","slug":"weird-coroutines-reference-issue","status":"publish","type":"post","link":"https:\/\/woohuiren.me\/blog\/weird-coroutines-reference-issue\/","title":{"rendered":"Weird Coroutines Reference Issue"},"content":{"rendered":"\n<p>Recently, I encountered a weird issue with coroutines in Kotlin. A library that references a coroutine version that differed from my Kotlin&#8217;s coroutine could not compile. It resulted in the following error being displayed.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Cannot access 'kotlinx.coroutines.CoroutineScope' which is a supertype of '.....'.<\/pre>\n\n\n\n<p>This is probably related to an Application Binary Interface (ABI) issue where a low-level C compiled code has some non-breaking changes but as the ABI has changed, a recompilation is required. In this case, I could either recompile Kotlin coroutines + referenced library, or I could just state the same exact coroutine version used by the referenced library.<\/p>\n\n\n\n<p>In my Gradle build (build.gradle) file, I added this new line:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">compile group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: coroutinesVersion<\/pre>\n\n\n\n<p>And in my Gradle properties (gradle.properties) file, I specified my the variable:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">coroutinesVersion=1.3.2<\/pre>\n\n\n\n<p>If you&#8217;re using Maven, then you can change your configuration like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">&lt;properties&gt;\n     &lt;coroutines.version&gt;1.3.2&lt;\/kotlin.version&gt;\n&lt;\/properties&gt;\n...\n&lt;dependency&gt;\n    &lt;groupId&gt;org.jetbrains.kotlinx&lt;\/groupId&gt;\n    &lt;artifactId&gt;kotlinx-coroutines-core&lt;\/artifactId&gt;\n    &lt;version&gt;${coroutines.version}&lt;\/version&gt;\n&lt;\/dependency&gt;<\/pre>\n\n\n\n<p>The fix is absurdly easy despite of the weird and cryptic error message. I hope this was helpful to you and helped you understood what might have happened to cause this issue to occur. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Recently, I encountered a weird issue with coroutines in Kotlin. A library that references a coroutine version that differed from my Kotlin&#8217;s coroutine could not compile. It resulted in the following error being displayed. Cannot access &#8216;kotlinx.coroutines.CoroutineScope&#8217; which is a supertype of &#8216;&#8230;..&#8217;. This is probably related to an Application Binary Interface (ABI) issue where &hellip; <a href=\"https:\/\/woohuiren.me\/blog\/weird-coroutines-reference-issue\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Weird Coroutines Reference Issue&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":863,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[2,5],"tags":[207,210,208,209],"class_list":["post-862","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-information-technology","category-programming","tag-coroutines","tag-gradle","tag-kotlin","tag-maven"],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/i0.wp.com\/woohuiren.me\/blog\/wp-content\/uploads\/2021\/02\/coroutine.png?fit=1920%2C1080&ssl=1","_links":{"self":[{"href":"https:\/\/woohuiren.me\/blog\/wp-json\/wp\/v2\/posts\/862"}],"collection":[{"href":"https:\/\/woohuiren.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/woohuiren.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/woohuiren.me\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/woohuiren.me\/blog\/wp-json\/wp\/v2\/comments?post=862"}],"version-history":[{"count":2,"href":"https:\/\/woohuiren.me\/blog\/wp-json\/wp\/v2\/posts\/862\/revisions"}],"predecessor-version":[{"id":865,"href":"https:\/\/woohuiren.me\/blog\/wp-json\/wp\/v2\/posts\/862\/revisions\/865"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/woohuiren.me\/blog\/wp-json\/wp\/v2\/media\/863"}],"wp:attachment":[{"href":"https:\/\/woohuiren.me\/blog\/wp-json\/wp\/v2\/media?parent=862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/woohuiren.me\/blog\/wp-json\/wp\/v2\/categories?post=862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/woohuiren.me\/blog\/wp-json\/wp\/v2\/tags?post=862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}