Flutter "Namespace Not Specified" Error: The 4-Step Fix for AGP 8

By · Published 2026-11-29 · Last verified 2026-11-29

What does "Namespace not specified" mean in a Flutter Android build?

It means one Android module in your build, almost always an older Flutter plugin, doesn't declare a namespace in its build.gradle file, and Android Gradle Plugin (AGP) 8 refuses to build without one. Google's AGP 8.0 release notes list it as a breaking change: "You must set the namespace in the module-level build.gradle.kts file, rather than the manifest file." Older plugins still keep their package name in the package attribute of AndroidManifest.xml, so the build stops as soon as your project moves to AGP 8. The error message includes the path of the module that needs fixing, and that path tells you which of the fixes below applies. This guide was checked against the Android developer docs, the AGP 8.0 release notes and the Flutter issue tracker on 2026-11-29.

Grid of the 4-step Namespace Fix: read the module path in the error, upgrade plugins with flutter pub upgrade --major, add a namespace to android/app, use a fork or root Gradle patch only as a stopgap, noting AGP 8.0 makes namespace mandatory and never editing files in .pub-cache
The 4-step Namespace Fix for AGP 8.

The Namespace Fix: 4 steps

Short answer: read the module path in the error, upgrade that plugin, add the namespace yourself only if the module is your own, and patch an abandoned plugin only as a stopgap.

  1. Read the module path. The error names a project, such as A problem occurred configuring project ':some_plugin', and a build file path. A path inside your .pub-cache folder means a plugin. A path ending in android/app/build.gradle means your own app module.
  2. Upgrade the plugin. Run flutter pub outdated to see newer versions, then flutter pub upgrade --major-versions, flutter clean and flutter pub get. Read the plugin's changelog first, because a major version can change its API.
  3. Add the namespace to your own module. If the error points at android/app, add namespace inside the android { } block, normally with the same value as your applicationId.
  4. Stopgap for an abandoned plugin. If no fixed version exists, fork the plugin and add the namespace, or set it from your root android/build.gradle as shown below. Then plan a replacement.

Why did this start after an upgrade?

Short answer: AGP 7.3 introduced the namespace property and AGP 8.0 made it mandatory, so any plugin that skipped it breaks the moment your project uses AGP 8.

The namespace is the Kotlin or Java package used for a module's generated R class, which is how code reaches its resources. Android's module configuration guide says the namespace is defined "by the namespace property in your module's build.gradle.kts file". Before AGP 8, a library could still provide it through the package attribute in its manifest. A Flutter plugin's Android code is a Gradle library module like any other, so the rule applies to every plugin in your pubspec.yaml, not only to your app.

Flutter's own tracker confirmed this early. In Flutter issue 125181, a Flutter team member summed it up: "AGP 8.0 requires the entire plugin ecosystem to add namespace to their build.gradle files." The same thread notes that apps using integration_test needed Flutter 3.10 to build with AGP 8. Toolchain upgrades, like the Gradle and SDK bumps in our Android 16 (API 36) upgrade guide for Google Play, are the usual moment this error appears.

Which module does the error point to?

Short answer: the file path in the message decides the fix, so copy it before you change anything.

Path in the errorWhat it isFix
.../.pub-cache/hosted/pub.dev/<plugin>-<version>/android/build.gradleA plugin from pub.devUpgrade it; if it's abandoned, replace or fork it
.../.pub-cache/git/<plugin>.../android/build.gradleA plugin pulled from a Git repositoryAdd the namespace in that repository and update the ref
android/app/build.gradle or .ktsYour own app moduleAdd namespace in the android { } block

Don't edit the copy inside .pub-cache. It's a shared download cache, and your change disappears on the next clean fetch, including on CI.

Two columns comparing an error path inside .pub-cache, meaning a pub.dev or Git plugin to upgrade, replace or fork, with an error path in android/app, meaning your own module needs a namespace line matching the application ID
Which module the error points to.

How do you add the namespace to your own app module?

Short answer: add one line inside the android { } block of android/app/build.gradle, using the same value as your application ID.

// android/app/build.gradle.kts
android {
    namespace = "com.example.myapp"
    defaultConfig {
        applicationId = "com.example.myapp"
    }
}

// android/app/build.gradle (Groovy)
android {
    namespace "com.example.myapp"
}

Android's guide recommends keeping the namespace "the same as your application ID, as they are by default". The two are separate settings, though. The application ID is the identity Google Play uses for your app. The namespace only names the generated R class. The guide also warns that if you don't set applicationId explicitly, it takes the namespace's value, so changing the namespace would change your app's identity. Keep applicationId set and unchanged. After the edit, remove the package="..." attribute from android/app/src/main/AndroidManifest.xml if it's still there, then run a full flutter build appbundle.

What if the plugin is abandoned?

Short answer: replace it with a maintained package if one exists; otherwise fork it, or use a root-level Gradle patch as a temporary bridge.

A fork is the cleanest stopgap. Add the namespace in the fork's android/build.gradle and remove the manifest package attribute. Then point your app at the fork with a git dependency, or with dependency_overrides, both described in Dart's package dependencies documentation.

The widely shared alternative sets a namespace for every library module that lacks one from your root android/build.gradle:

// android/build.gradle (Groovy), placed ABOVE the
// subprojects { project.evaluationDependsOn(":app") } block
subprojects {
    afterEvaluate { project ->
        if (project.hasProperty("android") && project.android.namespace == null) {
            project.android.namespace = project.group
        }
    }
}

Placement matters. Gradle's API documentation for afterEvaluate says: "If the project has already been evaluated, this method fails." Below the evaluationDependsOn(":app") block, some modules are already evaluated, so the patch errors out instead of helping. Treat it as temporary, because it hides which plugins still need an update and the guessed namespace may not match the plugin's real package. Remove it once every plugin ships its own namespace.

Four-step flow showing where the root Gradle patch goes: android/build.gradle at the project root, a subprojects afterEvaluate block that sets the namespace, placed above evaluationDependsOn(':app'), removed once plugins update
Where the stopgap patch goes in android/build.gradle.

How do you check the fix held?

Short answer: run a release build from a clean state, then test the release build on a device before you upload it.

We build and ship Flutter apps on Google Play at GSPTeck, giosaia's indie studio building mobile and web apps with Flutter and Firebase, and plugin upgrades like this one are part of every toolchain bump.

FAQ

Should the namespace match my applicationId?

Usually yes. Android's guide recommends keeping them the same, but they're separate settings. Keep applicationId set explicitly so a namespace change never changes your app's identity on Google Play.

Can I fix this by downgrading AGP?

It removes the error but keeps your project on an old toolchain, and the error returns at the next upgrade. Upgrading or replacing the plugin is the lasting fix.

Why shouldn't I edit the plugin inside .pub-cache?

The pub cache is a shared download folder. Your edit isn't part of your project, so a fresh fetch, another machine or a CI run brings the error back.

Does the root build.gradle patch work with Kotlin DSL files?

The same idea works in build.gradle.kts, but the syntax differs. Keep it above the evaluationDependsOn block in either language, and remove it once the plugins are updated.

Sources

Vertical Pinterest graphic with five points on fixing the Flutter Namespace not specified error
Pinterest pin: Flutter Namespace not specified.