Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No matching variant for sqldelight android driver in KMM

I'm encountering a build error when using a custom build type ("snapshot") in my KMM (Kotlin Multiplatform Mobile) project with SQLDelight. The debug build works perfectly fine, but the snapshot build throws an error:

Could not resolve all files for configuration ':android:app:snapshotRuntimeClasspath'.
Could not resolve app.cash.sqldelight:android-driver:2.0.0.
Required by:
project :android:app
project :android:app > project :kmp:shared > project :kmp:core-db

> No matching variant of app.cash.sqldelight:android-driver:2.0.0 was found.

Here's my KMM source sets configuration:

kotlin {
  sourceSets {
    commonMain.dependencies {
      implementation(project(":kmp:core"))
      implementation(project(":kmp:core-api"))
      implementation(libs.sqldelight.runtime)
      implementation(libs.korlibs.klock)
      api(libs.sqldelight.flow.ext)
      api(libs.sqldelight.primitive.adapters)
    }

    androidMain.dependencies {
      implementation(libs.sqldelight.android.driver)
    }

    iosMain.dependencies {
      implementation(libs.sqldelight.native.driver)
    }
  }
}

I've tried the following but haven't found a solution:

buildTypes {
        getByName("snapshot"){
            initWith(getByName("release"))
            matchingFallbacks.addAll(listOf("debug, release"))
        }
    }
   
like image 835
Suraj Giri Avatar asked Oct 12 '25 01:10

Suraj Giri


2 Answers

I think your matchingFallbacks syntax is wrong. Try changing it to matchingFallbacks.addAll(listOf("debug", "release"))

like image 80
RussHWolf Avatar answered Oct 14 '25 14:10

RussHWolf


You are quite close with matchingFallbacks here. I have the same problem and we have a multimodule project.

This article points that you need to specify matchingFallbacks for "snapshot" build type of every module. In our case it solved the problem.

like image 45
Roman Chumachenko Avatar answered Oct 14 '25 16:10

Roman Chumachenko