"Suspicious receiver type; this does not apply to the current receiver of type ApplicationExtension" after upgrading to AGP 9


In build.gradle.kts (app),

> Suspicious receiver type; this does not apply to the current receiver > of type ApplicationExtension. This will apply to a receiver of type > Project, found in one of the enclosing lambdas. Make sure it's > declared in the right place in the file.

Gradle Plugin: 9.3.1

Android Gradle Plugin (AGP): 9.0.0

Android Studio Otter 3

I'm seeing above error on following kotlin JVM declaration

kotlin {
    compilerOptions {
        jvmTarget.set(JvmTarget.JVM_17)
    }
}

how to fix this?

2
Feb 4 at 12:19 PM
User AvatarSohaib Ahmed
#android#android-studio#android-gradle-plugin#gradle-plugin

Accepted Answer

This occurs when you note the kotlin block inside of the android block, like this:

android {
    // ...

    kotlin {
        compilerOptions {
            jvmTarget.set(JvmTarget.JVM_17)
        }
    }
}

The kotlin block belongs on the top-level of the gradle file though, so it looks like this:

android {
    // ...
}

kotlin {
    compilerOptions {
        jvmTarget.set(JvmTarget.JVM_17)
    }
}

That said, with AGP 9 you do not even need to provide the jvmTarget explicitily because AGP will set it to android.compileOptions.targetCompatibility by default. If this is the only thing you use the kotlin block for then the proper solution would be to simply remove it entirely.

User Avatartyg
Feb 4 at 3:38 PM
0