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.

Fail to generate DatabaseInterface

See original GitHub issue

Build Environment SQLDelight version: 1.5.0 OS: Multiplatform (KMM for Android and Ios) Gradle version: 4.2.0 Kotlin version: 1.5.0

Describe the bug After installing the plugin, I created the sq file but the build fails for the following reason:

"Execution failed for task ‘:shared:generateCommonMainAppDatabaseInterface’. A failure occurred while executing com.squareup.sqldelight.gradle.SqlDelightTask$GenerateInterfaces ‘void kotlin.jvm.internal.FunctionReferenceImpl.<init>(int, java.lang.Class, java.lang.String, java.lang.String, int)’

Gradle’s dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)

Re-download dependencies and sync project (requires network) The state of a Gradle build process (daemon) may be corrupt. Stopping all Gradle daemons may solve this problem.

Stop Gradle build processes (requires restart) Your project may be using a third-party plugin which is not compatible with the other plugins in the project or the version > of Gradle requested by the project.

In the case of corrupt Gradle processes, you can also try closing the IDE and then killing all Java processes.

App Gradle file

buildscript {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
    dependencies {
        classpath("com.squareup.sqldelight:gradle-plugin:1.5.0")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.32")
        classpath("com.android.tools.build:gradle:4.2.0")
        classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.3.5")
       }
}

allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

Shared Gradle file

import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget

plugins {
    kotlin("multiplatform")
    id("com.android.library")
    kotlin("native.cocoapods")
    id("androidx.navigation.safeargs.kotlin")
    id("kotlin-parcelize")
    id ("org.jetbrains.kotlin.kapt")
    id ("com.squareup.sqldelight")
}

version = "1.0.0"

kotlin {
    android()
    ios {}

    cocoapods {
        summary = "Some description for a Kotlin/Native module"
        homepage = "Link to a Kotlin/Native module homepage"

    }
    sourceSets {
        val commonMain by getting{
            dependencies{
                implementation ("com.squareup.sqldelight:runtime:1.5.0")
                val kotlin_version = "1.5.0"
                implementation ("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
                api ("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8")
                api ("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8")
                implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.2.0")
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(kotlin("test-common"))
                implementation(kotlin("test-annotations-common"))
            }
        }
        val androidMain by getting {
            dependencies {
                implementation("com.google.android.material:material:1.2.1")
                implementation ("com.squareup.sqldelight:android-driver:1.5.0")
            }
        }
        val androidTest by getting {
            dependencies {
                implementation(kotlin("test-junit"))
                implementation("junit:junit:4.13")
            }
        }
        val iosMain by getting {
            dependencies {
                implementation("com.squareup.sqldelight:native-driver:1.5.0")
            }
        }

        val iosTest by getting
    }
}

android {
    compileSdkVersion(29)
    sourceSets["main"].manifest.srcFile("src/androidMain/AndroidManifest.xml")
    defaultConfig {
        minSdkVersion(24)
        targetSdkVersion(29)
    }
    //mancano exclude("META-INF/DEPENDENCIES") ..dexOptions
    //aggiungo
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    buildFeatures{
        viewBinding = true
    }

}

sqldelight {
    database("AppDatabase") {
        packageName = "com.drp.giacami.shared"
    }
}

val packForXcode by tasks.creating(Sync::class) {
    group = "build"
    val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
    val sdkName = System.getenv("SDK_NAME") ?: "iphonesimulator"
    val targetName = "ios" + if (sdkName.startsWith("iphoneos")) "Arm64" else "X64"
    val framework = kotlin.targets.getByName<KotlinNativeTarget>(targetName).binaries.getFramework(mode)
    inputs.property("mode", mode)
    dependsOn(framework.linkTask)
    val targetDir = File(buildDir, "xcode-frameworks")
    from({ framework.outputDirectory })
    into(targetDir)
}

tasks.getByName("build").dependsOn(packForXcode)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

4reactions
youyingfengcommented, May 13, 2021

Encountered a similar bug on Android Studio, managed to fix it by updating the gradle version (under Files > Project Structure > Project) to 7.0.1 (originally was 6.7.1). I referenced #2344 for the fix.

3reactions
Phalaencommented, May 13, 2021

Thank you, I can confirmed that it was a problem of gradle version in Android Studio. With the following combination it works and it builds the interface: Gradle 6.8.3 Android tools build gradle 4.2.0 Kotlin gradle plugin 1.5.0 Kotlin version 1.5.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Database Interface Designer encounters error, "Failed to Load ...
Answer. To resolve this error: - Make sure DB2 client is installed on your Windows system. - Make sure DB2 client in your...
Read more >
phpMyAdmin error in DatabaseInterface.class.php
The site notes that it is just a notice - which can be disabled. Comment the following line: error_reporting = E_ALL & ~E_DEPRECATED....
Read more >
How To Fix the "Error Establishing a Database Connection" in ...
1. Error Message After Migrating a Site or Creating a New Site · Check Your Database Login Credentials · Create New Database User...
Read more >
This error is coming up when I upgrade to php 7 version to php 8
Fatal error: Unparenthesized a ? b : c ? d : e is not supported. ... b : (c ? d : e)...
Read more >
Unable to connect to Sybase DB from PowerBuilder Version ...
While trying to create a new DB profile it is giving the error "Unable to load the requested Database Interface. Please make.
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