Hey everyone I upgraded Kotlin Version to 1.9.20 B...
# multiplatform
v
Hey everyone I upgraded Kotlin Version to 1.9.20 But now in Shared Module build.gradle.kts, I’m getting these error on Sync
Copy code
e: file:///Volumes/Files/Medial/MedialMultiplatform/shared/build.gradle.kts:18:5: Unresolved reference: androidTarget
e: file:///Volumes/Files/Medial/MedialMultiplatform/shared/build.gradle.kts:93:9: Unresolved reference: androidMain
e: file:///Volumes/Files/Medial/MedialMultiplatform/shared/build.gradle.kts:119:9: Unresolved reference: iosMain
This is my project Gradle
Copy code
plugins {
    //trick: for the same plugin versions in all sub-modules
    id("com.android.application").version("8.2.0-beta06").apply(false)
    id("com.android.library").version("8.2.0-beta06").apply(false)
    kotlin("multiplatform").version(libs.versions.kotlin.get()).apply(false)
    id("com.codingfeline.buildkonfig").version("0.14.0").apply(false)
    kotlin("plugin.serialization").version("1.4.21").apply(false)
    id("org.jetbrains.compose").version(libs.versions.compose.get()).apply(false)
    id("com.google.gms.google-services").version("4.3.14").apply(false)
    alias(libs.plugins.crashlytics).apply(false)
}
Shared Gradle
Copy code
import com.codingfeline.buildkonfig.compiler.FieldSpec.Type.STRING
plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    id("com.android.library")
    id("app.cash.sqldelight") version "2.0.0"
    kotlin("plugin.serialization")
    id("com.codingfeline.buildkonfig")
    id("org.jetbrains.compose")
    id("dev.icerock.mobile.multiplatform-resources")
}

@OptIn(org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi::class)
kotlin {
    jvmToolchain(11)
    androidTarget()
    iosArm64()
    iosSimulatorArm64()

    cocoapods {
        summary = "Some description for the Shared Module"
        homepage = "Link to the Shared Module homepage"
        version = "1.0"
        ios.deploymentTarget = "14.1"
        podfile = project.file("../iosApp/Podfile")
        framework {
            baseName = "shared"
            isStatic = true
        }

        pod("Amplitude", "8.17.1")
        pod("FirebaseMessaging")
        pod("FirebaseAuth")
        pod("Reachability")
        pod("GoogleSignIn")
        pod("lottie-ios") {
            version = "4.3.3"
            moduleName = "Lottie"
        }
    }
    
    sourceSets {
       
        commonMain {
            dependencies {
                ………………….
            }
        }

        commonMain {
            dependencies {
                implementation(kotlin("test"))
            }
        }

        androidMain {
            dependencies {
                ……………………….
            }
        }

        iosMain {
            dependencies {
                ………………….
            }
        }
    }
}
c
this build files are not using the kotlin dsl. for
getting
the configurations you need to use something like
val androidMain by getting
v
Even in Kotlin 1.9.20?
c
yes, your syntax is groovy.
v
@Chrimaeon https://kotlinlang.org/docs/whatsnew1920.html#use-completion-for-source-sets This shows we can use it without
by getting
It’s not detecting
androidTarget
too
c
It doesn’t say that this is Kotlin dsl.
v
Okay, so I tried with
getting
this is what I get while syncing
Copy code
After that, replace `by getting` with static accessors:

  sourceSets {
      commonMain { ... }
      
      iosMain {
          dependencies { ... }
      }
  }
c
then I’m out of ideas.
v
No issues, thanks for helping out
c
what is the sentance before
After that
? did you doo that?
v
to not use
ios()
and rather specify
iOSArm64()
etc ..
These are just warnings
c
👍
j
This is correct, you can use static accessors for default hierarchy template source sets instead of
by getting
with Kotlin 1.9.20. I'm assuming this:
Copy code
commonMain {
    dependencies {
        implementation(kotlin("test"))
    }
}
is actually:
Copy code
commonTest {
    dependencies {
        implementation(kotlin("test"))
    }
}
I'd make sure you're running the latest version of plugins and dependencies. In this case there was an issue because of the Build Konfig plugin, which it looks like you are using as well.
v
@Jeff Lockhart I’ve tried by removing buildKonfig as well, commonMain and commonTest are wokring, but its still unable to detect androidMain and iosMain, as well as androidTarget
d
It seems like for some reason you’re actually getting a version of KGP older than 1.9.20. This can happen if other Gradle plugins have “hard” dependencies on KGP and if they are not updated. It’s hard to be more precise without having a full access to buildscripts (settings.gradle.kts, convention plugins if any, etc.)
v
The Android Studio version I’m using Hedgehog Beta 6, it has Kotlin Plugin 1.9.10, can this be the cause?
j
The Kotlin IDE plugin shouldn't affect the actual build.
v
@लातों वाला भूत
253 Views