Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

Gradle says there is no signature of method android() in the build script

ErrorNo signature of method: build_<hash>.android()

Short answer

Gradle only knows the android block after the Android Gradle plugin is applied to that project. The block belongs in the module build file, such as app/build.gradle, under a plugins block that applies com.android.application. In the root file the plugin is declared with apply false, so android is not available there.

  • Applies to Gradle 8 or 9, Android Gradle Plugin 8.x or 9.x, Android Studio Otter
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Find which file the error names. Then check whether it is the root build.gradle or the module build.gradle.

    ls build.gradle* app/build.gradle*
  2. 2Match what you see, then jump to its fix

    1. 1The error names the build.gradle in the project rootThe android block is in the top-level build fileFix
    2. 2The error names the module build.gradle and the file has no plugins block with com.android.applicationThe module file does not apply the Android pluginFix

What does the error look like?

  • No signature of method: build_<hash>.android()
  • Gradle sync fails in a build.gradle file that contains an android block

Cause 1 of 2

The android block is in the top-level build file

1Check

The root file declares plugins with apply false: they become available to modules but are not applied to the root project, so the android block does not exist there.

grep -n "android {\|apply false" build.gradle*

2Fix

Move the android block to the module file (for example app/build.gradle). Keep only plugin declarations in the root file.

// build.gradle (root)
plugins {
    id 'com.android.application' version '9.5.0' apply false
}

// app/build.gradle (module)
plugins {
    id 'com.android.application'
}
android {
    namespace 'com.example.myapp'
    compileSdk 36
}

3Verify

Sync Gradle; the error is gone.

./gradlew help

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 2

The module file does not apply the Android plugin

1Check

The first lines of the module file apply the Android Gradle plugin; that is what makes the android block available.

head -n 12 app/build.gradle

2Fix

Apply the plugin at the top of the module file, above the android block.

plugins {
    id 'com.android.application'
}

3Verify

Sync Gradle and run a build.

./gradlew assembleDebug

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Keep the root file for plugin versions and the module files for the android block.
  • Compare a broken build file with a file from a new Android Studio project; the default layout is documented.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Android Studio cannot pair the phone over Wi-Fi

The Pair devices over Wi-Fi dialog lists no device

Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.

4 causes, each with a fix

Mobile apps

adb tcpip 5555 fails because no device is found

adb: more than one device/emulator

adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.