Unable to Resolve either AndroidSqlDriver or NativeSqlDriver in Multiplatform project
See original GitHub issueFirst off, thank you for this terrific library! I’m not able to create an instance of either the AndroidSqlDriver or the NativeSqlDriver, the following is how my project is set up:
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
plugins {
kotlin("multiplatform")
id("kotlin-android-extensions")
id("org.jetbrains.kotlin.plugin.serialization") version "1.3.61"
id("com.squareup.sqldelight")
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
jcenter()
maven("https://kotlin.bintray.com/kotlinx")
}
sqldelight {
database("MyDatabase") {
packageName = "org.example.KMPA"
}
}
androidExtensions {
isExperimental = true
}
kotlin {
//select iOS target platform depending on the Xcode environment variables
val iOSTarget: (String, KotlinNativeTarget.() -> Unit) -> KotlinNativeTarget =
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
::iosArm64
else
::iosX64
iOSTarget("ios") {
binaries {
framework {
baseName = "KMPA"
}
}
}
jvm("android")
val ktorVersion = "1.3.0"
val koinVersion = "2.0.1"
val coroutinesVersion = "1.3.3"
val serializationVersion = "0.14.0"
val sqldelightVersion = "1.2.2"
sourceSets["commonMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib-common")
implementation("org.koin:koin-core:$koinVersion")
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:$coroutinesVersion")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-common:$serializationVersion")
implementation("com.squareup.sqldelight:runtime:$sqldelightVersion")
implementation("com.squareup.sqldelight:runtime-metadata:$sqldelightVersion")
}
sourceSets["androidMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serializationVersion")
implementation("io.ktor:ktor-client-android:$ktorVersion")
implementation("com.squareup.sqldelight:android-driver:$sqldelightVersion")
}
sourceSets["iosMain"].dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation("io.ktor:ktor-client-ios:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:$coroutinesVersion")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime-native:$serializationVersion")
implementation("com.squareup.sqldelight:native-driver:$sqldelightVersion")
}
}
val packForXcode by tasks.creating(Sync::class) {
val targetDir = File(buildDir, "xcode-frameworks")
/// selecting the right configuration for the iOS
/// framework depending on the environment
/// variables set by Xcode build
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
val framework = kotlin.targets
.getByName<KotlinNativeTarget>("ios")
.binaries.getFramework(mode)
inputs.property("mode", mode)
dependsOn(framework.linkTask)
from({ framework.outputDirectory })
into(targetDir)
/// generate a helpful ./gradlew wrapper with embedded Java path
doLast {
val gradlew = File(targetDir, "gradlew")
gradlew.writeText(
"#!/bin/bash\n"
+ "export 'JAVA_HOME=${System.getProperty("java.home")}'\n"
+ "cd '${rootProject.rootDir}'\n"
+ "./gradlew \$@\n"
)
gradlew.setExecutable(true)
}
}
tasks.getByName("build").dependsOn(packForXcode)
// Top-level build file
buildscript {
ext.kotlin_version = '1.3.61'
ext.sqldelight_version = '1.2.2'
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.squareup.sqldelight:gradle-plugin:$sqldelight_version"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Now when I try to create an instance of say AndroidSqlDriver
from ../androidMain/..
I have no luck.
Issue Analytics
- State:
- Created 4 years ago
- Comments:12
Top Results From Across the Web
Could not resolve com.squareup.sqldelight:native-driver:1.3.0
I am trying to build a Kotlin multiplatform project to serve as a shared module for iOS and Android app. I am trying...
Read more >Support hierarchical KMM · Issue #2044 · cashapp/sqldelight
In Android Studio the code is compiled but when I run the build in Xcode I encounter the following problem: "FAILURE: Build failed...
Read more >Create a multiplatform app using Ktor and SQLDelight – tutorial
In Android Studio, select File | New | New Project. In the list of project templates, select Kotlin Multiplatform App and then click...
Read more >shared'. in KMM Project for cross Platform. Can some one help ...
I am unable to resolve exception is Task 'embedAndSignAppleFrameworkForXcode' not found in project ':shared'. in KMM Project for cross Platform. Can some one ......
Read more >Kotlin Multiplatform. Very beginner's guide (part 3) Database
For creating SQL tables and requests SqlDelight uses a special file with the instruction that has to be placed inside the sqlDelight folder....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s part of a new tutorial for Kotlin Multiplatform. Not public yet, but I added you. You should have an invite.
This is a kts gradle script, but a more “complete” config. Note the android target, and android as a library