Gradle says it could not get unknown property 'android' for the root project
Could 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.
Fix it fast
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/null2Match what you see, then jump to its fix
- 1
The 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
The 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
- 1
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/null2Fix
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 --debugConfirmed by developer.android.com
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.gradle2Fix
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 projectsConfirmed by developer.android.com
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:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- Dispatch ProA real-time logistics platform: Flutter apps, Spring Boot services and a Kafka event pipeline on AWS.
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 fixMobile apps
Gradle cannot find com.google.firebase:firebase-analytics-ktx
Required by: project :app
Firebase moved the Kotlin extensions into the main modules and stopped releasing the -ktx modules in July 2025.
2 causes, each with a fixMobile apps
Gradle cannot create LibraryVariantBuilderImpl in a Flutter Android build
Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl
This error appears when the Android Gradle plugin (AGP) cannot run in the Gradle or IDE you use.
3 causes, each with a fixMobile apps
Flutter release build cannot open the keystore: HmacPBESHA256 not available
Algorithm HmacPBESHA256 not available
The keystore is a PKCS12 file protected by a newer algorithm than the Java that is reading it understands.
3 causes, each with a fixMobile apps
Android install error: the package conflicts with an existing package of the same name
The package conflicts with an existing package by the same name
Android allows only one app per application ID, and an update must be signed with the same certificate as the installed version.
3 causes, each with a fixMobile apps
Android resource linking fails with resource android:attr/lStar not found
error: failed linking references.
The lStar attribute exists only from Android API 31.
2 causes, each with a fix