https://kotlinlang.org logo
#android
Title
# android
m

Minn Khant Ko Ko

02/16/2023, 5:32 PM
Hello I am trying to work with SQLDelight. But I am having this error while I am trying to add SQLDelight in my sample project. This is the error message I've got.
Copy code
Build file 'C:\Users\Admin\AndroidStudioProjects\EPL\build.gradle' line: 14

A problem occurred evaluating root project 'EPL'.
> Could not find method sqldelight() for arguments [build_89x3k1k4m00uwhhcgyw1e5ue9$_run_closure1@fdcc24e] on root project 'EPL' of type org.gradle.api.Project.

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
org.gradle.api.GradleScriptException: A problem occurred evaluating root project 'EPL'.
	at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:93)
	at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.lambda$apply$0(DefaultScriptPluginFactory.java:133)
	at org.gradle.configuration.ProjectScriptTarget.addConfiguration(ProjectScriptTarget.java:79)
And this is my current top-level gradle file.
Copy code
buildscript {
    ext {
        compose_ui_version = '1.2.0'
    }
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
    id 'com.android.application' version '7.4.0' apply false
    id 'com.android.library' version '7.4.0' apply false
    id 'org.jetbrains.kotlin.android' version '1.7.0' apply false
    id "app.cash.sqldelight" version "2.0.0-alpha05" apply false
}


sqldelight {
    databases {
        Database {
            packageName = "com.kwk.epl"
        }
    }
}
I am following this documentation. Can someone help me with this?
c

Chrimaeon

02/16/2023, 6:10 PM
Remove the
apply false
from the sqldelight plugin if you already want to use it in this build script.
m

Minn Khant Ko Ko

02/16/2023, 7:00 PM
I am currently implemented with the stable version. But I will definitely try with the alpha version again with apply false removed. Thanks a lot for your answer.
c

Charlie Tapping

02/17/2023, 2:46 PM
Typically you don’t want to apply it to your root project, instead you can preload the plugin there with apply false. Then in your project which contains the sqldelight .sq files and needs the codegen you apply it in there
6 Views