Cross-posting from the gradle community slack (<ht...
# android
Cross-posting from the gradle community slack ( I'm trying to understand the root cause of this error message:
Copy code
* What went wrong:
An exception occurred applying plugin request [id: '', version: '1.4.21']
> Failed to apply plugin ''.
   > Extension with name 'android' does not exist. Currently registered extension names: [ext, kotlin, kotlinTestRegistry]
which is a result of the following setup:
Copy code
// root build.gradle
buildscript {
    repositories {
    dependencies {
        classpath ""
// app/build.gradle
plugins {
    id ''
    id '' version '1.4.21'
and then executing
./gradlew help
. Build scan: I recognize, btw, that this is a non-standard setup. To reiterate, my goal is to understand what that error means and why it happens.
relatedly, the kotlin-android plugin should be able to be applied this way, per docs on the gradle plugin portal
so I guess the question is, why can't the kotlin-android plugin "see" the
extension in the example above? It looks like, if KGP and AGP are loaded on the same classpath in the same script context, then there's no problem, but if KGP is in a child, then it barfs, and I don't understand why. If there's some ordering problem, I also don't understand that, since I apply AGP before I apply KGP, so
should exist, right?
i read this error as it’s missing the android extension dsl. what happens if you add this
Copy code
android {}
below the plugins block? i’d expect the error to go away or change slightly.
I ended up filing an issue against gradle for this tl;dr it looks like an ordering issue. In the failure case, KGP is applied first, before the android extension has been created by AGP. KGP does not use withPlugin or anything like that; it just assumes it is applied after AGP