question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error while importing the generated database

See original GitHub issue

Build Environment SQLDelight version: 1.4.1 OS: macOS 10.15.6 Gradle version: 6.6 Kotlin version: 1.4.0 IDE: Android Studio 4.0.1 and IntelliJ IDEA 2020.2 AGP Version (if applicable): 4.0.1

Describe the bug After migrating and building my project, I can not import the generated database from the commonMain nor androidMain source sets. However, I can import it from the iosMain source set.

When I try to import the database from the commonMain source set, the IDE says “Add dependency on module ‘common_iosMain’”. Similarly, on the androidMain source set, it says “Add dependency on on module ‘common_iosMain’” and “Import”, but the option “Import” does not work.

Common target

Android target

Additionally, after building, the IDE gives a warning:

Duplicate content roots detected: Path [/Users/Gianfranco/Documents/UPC-Mobile/common/build/generated/sqldelight/code/UpcDatabase] of module [common_iosMain] was removed from modules [common_commonMain]

build.gradle

plugins {
    kotlin("multiplatform")
    kotlin("native.cocoapods")
    kotlin("plugin.serialization")
    id("com.android.library")
    id("com.squareup.sqldelight")
}

android {
    compileSdkVersion(App.CompileSdk)
    buildToolsVersion(App.BuildTools)

    defaultConfig {
        minSdkVersion(App.MinSdk)
        targetSdkVersion(App.TargetSdk)
        versionCode = App.VersionCode
        versionName = App.VersionName
    }

    sourceSets {
        getByName("main") {
            manifest.srcFile(File("src/androidMain/AndroidManifest.xml"))
            java.srcDirs("src/androidMain/kotlin")
            res.srcDirs("src/androidMain/res")
        }

        getByName("test") {
            java.srcDirs("src/androidTest/kotlin")
            res.srcDirs("src/androidTest/res")
        }
    }
}

sqldelight {
    database("UpcDatabase") {
        packageName = "com.upc.common.sqldelight"
    }
}

version = "1.0"

kotlin {
    android()

    val onPhone = System.getenv("SDK_NAME")?.startsWith("iphoneos") ?: false
    if (onPhone) {
        iosArm64("ios")
    } else {
        iosX64("ios")
    }

    sourceSets["commonMain"].dependencies {
        implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.Coroutines}")
        implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:${Versions.Serialization}")
        implementation("io.ktor:ktor-client-core:${Versions.Ktor}")
        implementation("com.squareup.sqldelight:coroutines-extensions:${Versions.SqlDelight}")
        implementation("com.russhwolf:multiplatform-settings:${Versions.Settings}")
    }

    sourceSets["androidMain"].dependencies {
        implementation("io.ktor:ktor-client-android:${Versions.Ktor}")
        implementation("com.squareup.sqldelight:android-driver:${Versions.SqlDelight}")
    }

    sourceSets["iosMain"].dependencies {
        implementation("io.ktor:ktor-client-ios:${Versions.Ktor}")
        implementation("com.squareup.sqldelight:native-driver:${Versions.SqlDelight}")
    }

    sourceSets["commonTest"].dependencies {
        implementation("org.jetbrains.kotlin:kotlin-test-common:${Versions.Kotlin}")
        implementation("org.jetbrains.kotlin:kotlin-test-annotations-common:${Versions.Kotlin}")
    }

    sourceSets["androidTest"].dependencies {
        implementation("org.jetbrains.kotlin:kotlin-test:${Versions.Kotlin}")
        implementation("org.jetbrains.kotlin:kotlin-test-junit:${Versions.Kotlin}")
        implementation("com.squareup.sqldelight:sqlite-driver:${Versions.SqlDelight}")
    }

    targets.withType<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
        binaries.withType<org.jetbrains.kotlin.gradle.plugin.mpp.Framework> {
            isStatic = false
        }
    }

    cocoapods {
        summary = "UPC-Mobile with Kotlin/Native"
        homepage = "https://github.com/GianfrancoMS/UPC-Mobile"
        podfile = project.file("../iosApp/Podfile")
    }
}

tasks.getByName("podspec").enabled = false

gradle.properties

org.gradle.jvmargs=-Xmx1536m
org.gradle.caching=true
android.useAndroidX=true
android.useMinimalKeepRules=true
kotlin.incremental.usePreciseJavaTracking=true
kotlin.code.style=official
kotlin.mpp.enableGranularSourceSetsMetadata=true
kotlin.native.enableDependencyPropagation=false
xcodeproj=./iosApp

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:13
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
AlecStrongcommented, Aug 25, 2020

please try latest snapshot release to see if it fixes

1reaction
sigurdurrafncommented, Aug 28, 2020

It looks like 1.4.2 has been released, which includes the fix. So no need for snapshot and the snapshot repo

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting database import errors
This error message indicates that you don't have sufficient permissions to create the new database, which is caused by the CREATE DATABASE ...
Read more >
Error importing database locally on XAMPP | Drupal.org
This Error, Mostly We get while importing the database from PhpMyAdmin. I solved it by importing database through commands. mysql -u username -p ......
Read more >
error while importing database - Oracle Communities
Cause: The import failed because the DDL had insufficient privileges. Action: Connect as SYSDBA and run the SQL file.
Read more >
Error while importing database - WordPress Stack Exchange
When exporting from original database you should choose to create the tables if they dosn't exist (First error). If you didn't choose that ......
Read more >
Shopware import Database runs on "GENERATED ALWAYS ...
Shopware import Database runs on "GENERATED ALWAYS AS" error · Seems like I have this origin: "Server-Version: 10.4. · It works fine here....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found