Maaz Zindani

Loading the index…

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

Gradle says it could not get unknown property 'android' for the root project

ErrorCould not get unknown property 'android' for root project 'android' of type org.gradle.api.Project.

Short answer

The android block is added by the Android Gradle Plugin, and only to a project where that plugin is applied. The error means a script touches android on a project that has no AGP, usually the top-level build file. Move the android settings into the app module's build file, and apply the plugin there.

  • Applies to Android Gradle Plugin 8.x, Gradle 8.x, Flutter 3.35 android folder
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Read the file and line the error names; that is the build file that touches android. Then see which plugins that file applies.

    cd android
    ./gradlew projects
    grep -n "android\b" build.gradle build.gradle.kts 2>/dev/null
  2. 2Match what you see, then jump to its fix

    1. 1The error names android/build.gradle (the file in the android folder, not android/app/build.gradle)An android block or android setting sits in the top-level build fileFix
    2. 2The error names android/app/build.gradle, and its plugins block has no com.android.application (or com.android.library)The Android plugin is not applied in the module that uses androidFix

What does the error look like?

  • Could not get unknown property 'android' for root project 'android' of type org.gradle.api.Project.

Cause 1 of 2

An android block or android setting sits in the top-level build file

1Check

Android's build structure guide says the root build file should only declare plugins for a shared classpath. The android {} configuration belongs in the build file of each app or library module.

grep -n -B1 -A3 "android" build.gradle build.gradle.kts 2>/dev/null

2Fix

Cut the android block (or the script that reads project.android) out of the root file and put it in the module file, such as android/app/build.gradle.

// android/app/build.gradle
android {
    namespace = "com.example.app"
    compileSdk = 36
}

3Verify

Run a build again from the project.

flutter build apk --debug

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 2

The Android plugin is not applied in the module that uses android

1Check

Applying AGP is what registers its tasks and its android DSL. Without it, the word android is just an unknown property.

sed -n '1,20p' app/build.gradle

2Fix

Apply the plugin in the module's plugins block before the android block.

plugins {
    id "com.android.application"
}

3Verify

Gradle lists the project, and the configure step passes.

./gradlew projects

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Keep the root build file to plugin declarations; configure the app in the module file.
  • When you paste a snippet from a guide, check which file it is written for.
  • Read the file and line number in the first error line before changing anything.

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

Google Play says the app does not support 16 KB memory pages

check_elf_alignment.sh reports UNALIGNED for a library under lib/arm64-v8a

Google Play requires apps that target Android 15 or higher and ship native .so libraries to run on devices with 16 KB memory pages; from 1 February 2027 it will block updates that do not.

5 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.