Gradle says the Android namespace is not specified
Namespace not specified. Specify a namespace in the module's build file.Short answer
Android Gradle Plugin 8 reads the package name for R and BuildConfig from the namespace property in the module's build file, not from the manifest. Read the error to see which module lacks it, then add namespace to that module's android block. If the module is a pub plugin, try a newer version of it first.
Fix it fast
1Find out which cause you have
Read the first lines of the failure. They name the Gradle project (for example :app or :some_plugin) that has no namespace. That name decides which cause below applies.
cd android && ./gradlew :app:assembleDebug --stacktrace2Match what you see, then jump to its fix
- 1
The failing project is :app or a module you wroteYour own app or library module has no namespaceFix - 2
The failing project is a plugin, such as :some_pluginA package from pub.dev is an older release without a namespaceFix - 3
The AGP Upgrade Assistant blocks the upgrade, or tests fail after setting namespaceThe test namespace equals the main namespaceFix
- 1
What does the error look like?
Namespace not specified. Specify a namespace in the module's build file.A failure occurred while evaluating the project ':some_plugin'
Cause 1 of 3
Your own app or library module has no namespace
1Check
AGP 8.0 made the namespace required in the module-level build script. Older projects kept the package only in the manifest. Open the module's build file and look for namespace in the android block.
grep -n "namespace" android/app/build.gradle*
grep -n "package=" android/app/src/main/AndroidManifest.xml2Fix
Add namespace to the android block. Use the value that was in the manifest package attribute, which should match the base package where your Kotlin or Java code lives. Keep applicationId set explicitly, because without it the application ID follows the namespace.
android {
namespace "com.example.myapp"
defaultConfig {
applicationId "com.example.myapp"
}
}3Verify
Rebuild the module.
flutter build apk --debugConfirmed by developer.android.com
Cause 2 of 3
A package from pub.dev is an older release without a namespace
1Check
Plugins are Gradle modules too, so each needs a namespace under AGP 8. See whether a newer release of the plugin exists.
flutter pub outdated2Fix
Upgrade the plugin to its newest release. Plugin code is not in your project, so that is the first fix to try. If no release exists, the plugin needs a change from its authors.
flutter pub upgrade some_plugin3Verify
Build again and confirm the failure no longer names the plugin.
flutter build apk --debugConfirmed by developer.android.com
Cause 3 of 3
The test namespace equals the main namespace
1Check
Older AGP versions inferred the test namespace from the main one. Check whether testNamespace was set to the same value as namespace.
grep -rn "testNamespace" android/2Fix
Give the test source sets their own name. By default it is the main namespace with .test added. Never set both to the same value, or the namespaces collide.
android {
namespace "com.example.myapp"
testNamespace "com.example.myapp.test"
}3Verify
Run the unit tests for the module.
cd android && ./gradlew :app:testDebugUnitTestConfirmed by developer.android.com
How do I stop it coming back?
- Set namespace and applicationId explicitly in every module you own.
- Run flutter pub outdated before an AGP upgrade, so plugins that are behind show up first.
- Use the AGP Upgrade Assistant in Android Studio when you move to a new AGP major version.
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