Fail to generate DatabaseInterface
See original GitHub issueBuild 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:
- Created 2 years ago
- Comments:8
Top GitHub Comments
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.
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