Sonar Gradle Plugin crashes on AGP 9: 'AppExtension' does not exist for :app:sonarResolver task

Could not determine the dependencies of task ‘:sonar’.

Could not create task ‘:app:sonarResolver’.
Extension of type ‘AppExtension’ does not exist. Currently registered extension types: [ExtraPropertiesExtension, SonarExtension, SonarExtension, VersionCatalogsExtension, BasePluginExtension, SourceSetContainer, ReportingExtension, JavaToolchainService, JavaPluginExtension, KotlinAndroidProjectExtension, ApplicationExtension, ApplicationAndroidComponentsExtension, LintLifecycleExtension, GoogleServicesPlugin.GoogleServicesPluginConfig, KspExtension]

id("org.sonarqube") version "7.2.2.6593"
id("com.android.application") version "9.0.0" apply false
id("com.android.library") version "9.0.0" apply false
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip

Android Studio Otter 3 Feature Drop | 2025.2.3
Build #AI-252.28238.7.2523.14688667, built on January 9, 2026
Runtime version: 21.0.8±14196175-b1038.72 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.awt.windows.WToolkit
Windows 11.0
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 3072M
Cores: 20
Registry:
ide.experimental.ui=true

See:

https://developer.android.com/build/releases/agp-9-0-0-release-notes?buildsystem=ndk-build#updating-gradle

From the source code (sonar)

This bug happens local and also in our ci:

Now when I use following inside my gradle.properties:

android.newDsl=false

and change in my build.gradle.kts

android {

to

import com.android.build.api.dsl.ApplicationExtension

extensions.configure<ApplicationExtension>("android") {

The sonar plugin works again.

Here is the ouput after the working version:

$ gradle sonar

> Configure project :app

WARNING: The option setting ‘android.newDsl=false’ is deprecated.

The current default is ‘true’.

It will be removed in version 10.0 of the Android Gradle plugin.

> Task :sonarResolver

> Task :app:sonarResolver

Invocation of Task.project at execution time has been deprecated. This will fail with an error in Gradle 10. This API is incompatible with the configuration cache, which will become the only mode supported by Gradle in a future release. Consult the upgrading guide for further information: https://docs.gradle.org/9.1.0/userguide/upgrading_version_7.html#task_project

3 Likes

This has really high priority since this blocks basically all Android projects from properly updating to AGP 9.0. There is also no workaround inside sonar, since isSkipProject=true does not prevent the configurationAction of the SonarResolverTask: sonar-scanner-gradle/src/main/java/org/sonarqube/gradle/SonarQubePlugin.java at 6f92472b9256ede9512fd3c5cb4e81c5e94ebec4 · SonarSource/sonar-scanner-gradle · GitHub

@Colin Would be great if the sonar team could fix this ASAP. :folded_hands:

Hi,

This is flagged for the team.

 
Ann

1 Like

Hey @michael-winkler and @G00fY2,

Thank you for the heads up, we have had the support AGP 9 in the backlog for a while and we have re-prioritized it to tackle it in the coming days as discussed in this post.

2 Likes

@G00fY2 I was able to reproduce the issue discussed above when invoking the sonar task but not a configuration time. Would you mind sharing how you add the plugin to your configuration?

@Dorian_Burihabwa I also do not see the error message posted in the initial post. Our error message looks like this:

+ ./gradlew sonar --no-parallel
Calculating task graph as no cached configuration is available for tasks: sonar
> Task :build-logic:checkKotlinGradlePluginConfigurationErrors SKIPPED
> Task :build-logic:compileKotlin UP-TO-DATE
> Task :build-logic:compileJava NO-SOURCE
> Task :build-logic:pluginDescriptors UP-TO-DATE
> Task :build-logic:processResources UP-TO-DATE
> Task :build-logic:classes UP-TO-DATE
> Task :build-logic:jar UP-TO-DATE

FAILURE: Build failed with an exception.

* What went wrong:

Could not determine the dependencies of task ‘:sonar’.

> Extension of type ‘AppExtension’ does not exist. Currently registered extension types: [ExtraPropertiesExtension, SonarExtension, SonarExtension, LibrariesForLibs, VersionCatalogsExtension, RootProjectAccessor, BasePluginExtension, SourceSetContainer, ReportingExtension, JavaToolchainService, JavaPluginExtension, KotlinAndroidProjectExtension, ApplicationExtension, ApplicationAndroidComponentsExtension, LintLifecycleExtension, ComposeCompilerGradlePluginExtension, JacocoPluginExtension, SentryPluginExtension, DetektExtension, AboutLibrariesExtension, LicenseeExtension, HuaweiPublishExtension, KspExtension, HiltExtension, RoomExtension, AppDistributionExtension.DeprecatedAppDistributionExtension, AppDistributionExtension.ProjectDefaultAppDistributionExtension, GoogleServicesPlugin.GoogleServicesPluginConfig, BaselineProfileConsumerExtension]

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights from a Build Scan (powered by Develocity).
> Get more help at https://help.gradle.org.

BUILD FAILED in 4s

Your error message is different but the solution for this is the same.

2 Likes

This is not an sonar specific “solution” it’s a workaround to opt-out of the new AGP 9 DSL completely. This flag is well documented and it can be temporary used until all plugins are migrated.

But this discussion should be about supporting the Sonar team to actually fix/adopt the Sonar Gradle Plugin to this new DSL. :slight_smile:

I completely agree with you. I only meant this as a temporary solution until we no longer need android.newDsl=false to build the app.

1 Like