Unresolved Reference to android in build.gradle.kts – Beginner Issue

Hello,
I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the following configuration:

plugins {
    alias(libs.plugins.android.application) apply false
    alias(libs.plugins.kotlin.android) apply false
}

android {
    buildFeatures {
        viewBinding true
        dataBinding true
    }
}

However, I’m getting the error: Unresolved reference: android.
Can anyone help me understand what might be causing this issue? I’ve checked that I have the necessary Android Gradle plugins, but I’m not sure what I’m missing.

Any help would be greatly appreciated!

can you post what are your plugins inside libs.versions.toml?

@tsellami I’m getting the same problem. My libs.version.toml contains

[versions]
agp = “8.7.3”
kotlin = “1.9.24”
coreKtx = “1.15.0”
junit = “4.13.2”
junitVersion = “1.2.1”
espressoCore = “3.6.1”
appcompat = “1.7.0”
material = “1.12.0”
activity = “1.9.3”
constraintlayout = “2.2.0”
okhttp = “4.9.1”

[libraries]
androidx-core-ktx = { group = “androidx.core”, name = “core-ktx”, version.ref = “coreKtx” }
junit = { group = “junit”, name = “junit”, version.ref = “junit” }
androidx-junit = { group = “androidx.test.ext”, name = “junit”, version.ref = “junitVersion” }
androidx-espresso-core = { group = “androidx.test.espresso”, name = “espresso-core”, version.ref = “espressoCore” }
androidx-appcompat = { group = “androidx.appcompat”, name = “appcompat”, version.ref = “appcompat” }
material = { group = “com.google.android.material”, name = “material”, version.ref = “material” }
androidx-activity = { group = “androidx.activity”, name = “activity”, version.ref = “activity” }
androidx-constraintlayout = { group = “androidx.constraintlayout”, name = “constraintlayout”, version.ref = “constraintlayout” }
okhttp = { module = “com.squareup.okhttp3:okhttp”, version.ref = “okhttp” }

[plugins]
android-application = { id = “com.android.application”, version.ref = “agp” }
kotlin-android = { id = “org.jetbrains.kotlin.android”, version.ref = “kotlin” }