Gradle says there is no signature of method android() in the build script
No 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.
Fix it fast
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*2Match what you see, then jump to its fix
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 helpConfirmed by developer.android.com
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.gradle2Fix
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 assembleDebugConfirmed by developer.android.com
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
adb cannot start because something already holds its port
adb start-server failed
The adb server must bind local TCP port 5037, and every adb client talks to it there.
2 causes, each with a fixMobile apps
The phone shows as unauthorized and Android Studio will not run the app
adb devices lists the phone but Android Studio cannot deploy to it
An unauthorized phone means it has not trusted this computer's RSA key.
3 causes, each with a fixMobile 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 fixMobile apps
adb cannot connect to its daemon or start the server
* daemon started successfully *
The adb server is a background process on your computer that listens on TCP port 5037.
2 causes, each with a fixMobile apps
adb prints 'server version doesn't match this client; killing...'
adb server version doesn't match this client; killing...
adb runs a background server, and every adb command is a client.
3 causes, each with a fixMobile 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