I'm trying out KMM for the first time and when I try to rebuild the project, I get this error. Not sure what this task does. Am I the only one getting this error?
I'm using a Macbook Pro M1 that runs
Android Studio Iguana | 2023.2.1 Runtime version: 17.0.9+0-17.0.9b1087.7-11185874 aarch64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Executing tasks: [:androidApp:clean, :shared:clean,
:androidApp:assembleDebug, :androidApp:assembleDebugUnitTest,
:androidApp:assembleDebugAndroidTest, :shared:assembleDebug,
:shared:assembleDebugUnitTest, :shared:assembleDebugAndroidTest,
:shared:assemble, :shared:testClasses] in project
/Users/betteropinions/Development/KMM/TranslateKMMApp
Calculating task graph as no configuration cache is available for
tasks: :androidApp:clean :shared:clean :androidApp:assembleDebug
:androidApp:assembleDebugUnitTest
:androidApp:assembleDebugAndroidTest :shared:assembleDebug
:shared:assembleDebugUnitTest :shared:assembleDebugAndroidTest
:shared:assemble :shared:testClasses
Type-safe project accessors is an incubating feature.
FAILURE: Build failed with an exception.
* What went wrong:
Cannot locate tasks that match ':shared:testClasses' as task
'testClasses' not found in project ':shared'.
* Try:
> Run gradle tasks to get a list of available tasks.
> For more on name expansion, please refer to
https://docs.gradle.org/8.4/userguide/
command_line_interface.html#sec:
name_abbreviation in the Gradle documentation.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
BUILD FAILED in 1s
Configuration cache entry stored.
Below is the build.gradle.kts for shared module
plugins {
alias(libs.plugins.kotlinMultiplatform)
alias(libs.plugins.kotlinCocoapods)
alias(libs.plugins.androidLibrary)
alias(libs.plugins.kotlinSerialization)
id("com.squareup.sqldelight")
}
kotlin {
androidTarget {
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
iosX64()
iosArm64()
iosSimulatorArm64()
cocoapods {
summary = "Some description for the Shared Module"
homepage = "Link to the Shared Module homepage"
version = "1.0"
ios.deploymentTarget = "16.0"
podfile = project.file("../iosApp/Podfile")
framework {
baseName = "shared"
isStatic = true
}
}
sourceSets {
commonMain.dependencies {
//put your multiplatform dependencies here
implementation(libs.ktor.client.core)
implementation(libs.ktor.client.content.negotiation)
implementation(libs.ktor.serialization.kotlinx.json)
implementation(libs.sqldelight.coroutines.extensions)
implementation(libs.sqldelight.runtime)
implementation(libs.kotlinx.datetime)
}
commonTest.dependencies {
implementation(kotlin("test"))
implementation(libs.turbine)
implementation(libs.assertk)
}
androidMain.dependencies {
implementation(libs.ktor.client.android)
implementation(libs.sqldelight.android.driver)
}
iosMain.dependencies {
implementation(libs.ktor.client.darwin)
implementation(libs.sqldelight.native.driver)
}
}
}
android {
namespace = "com.example.mytranslate"
compileSdk = 34
defaultConfig {
minSdk = 24
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
sqldelight {
database("TranslateDatabase") {
packageName = "com.example.mytranslate.database"
sourceFolders = listOf("sqldelight")
}
}
This solution https://stackoverflow.com/a/78017056/6512100 works for me.
I've added task("testClasses")
within.in kotlin { }
block in build.gradle.kts (:shared)
file.
plugins {
...
}
kotlin {
androidTarget {
...
}
sourceSets {
...
}
task("testClasses")
}
android {
...
}