I'm trying to build my Flutter app with the flutter_secure_storage plugin but getting the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':flutter_secure_storage'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
> Namespace not specified. Specify a namespace in the module's build file. See for information about setting the namespace.
If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to for general information about using the AGP Upgrade Assistant.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at .
BUILD FAILED in 1s
Running Gradle task 'assembleRelease'... 1,874ms
Gradle task assembleRelease failed with exit code 1
Environment
- Flutter version: 3.5.2
- flutter_secure_storage version: 4.2.1
- OS: Linux
What I've tried
I've tried:
- Flutter clean and rebuild
- Updating the flutter_secure_storage plugin
- Looking for the build.gradle file to add namespace but I'm not sure where/how to properly configure it
Question
How do I fix this namespace issue with flutter_secure_storage? Do I need to modify the plugin's files directly or is there a way to fix this from my Flutter project? Has anyone encountered this specific error with this plugin before?
I'm particularly confused about:
- Where exactly I should add the namespace configuration
- What the correct namespace should be for flutter_secure_storage
- If there's a way to override this without modifying the plugin's code
Any help would be greatly appreciated!
I'm trying to build my Flutter app with the flutter_secure_storage plugin but getting the following error:
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':flutter_secure_storage'.
> Could not create an instance of type com.android.build.api.variant.impl.LibraryVariantBuilderImpl.
> Namespace not specified. Specify a namespace in the module's build file. See https://d.android/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.
If you've specified the package attribute in the source AndroidManifest.xml, you can use the AGP Upgrade Assistant to migrate to the namespace value in the build file. Refer to https://d.android/r/tools/upgrade-assistant/agp-upgrade-assistant for general information about using the AGP Upgrade Assistant.
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle..
BUILD FAILED in 1s
Running Gradle task 'assembleRelease'... 1,874ms
Gradle task assembleRelease failed with exit code 1
Environment
- Flutter version: 3.5.2
- flutter_secure_storage version: 4.2.1
- OS: Linux
What I've tried
I've tried:
- Flutter clean and rebuild
- Updating the flutter_secure_storage plugin
- Looking for the build.gradle file to add namespace but I'm not sure where/how to properly configure it
Question
How do I fix this namespace issue with flutter_secure_storage? Do I need to modify the plugin's files directly or is there a way to fix this from my Flutter project? Has anyone encountered this specific error with this plugin before?
I'm particularly confused about:
- Where exactly I should add the namespace configuration
- What the correct namespace should be for flutter_secure_storage
- If there's a way to override this without modifying the plugin's code
Any help would be greatly appreciated!
Share Improve this question asked Mar 15 at 17:44 Gabriel OkemwaGabriel Okemwa 214 bronze badges3 Answers
Reset to default 1This issue is because
namespace
is not specified. add the following code in your Project-level Gradle Fileandroid/build.gradle
allprojects { repositories { google() mavenCentral() } /* Add this code */ subprojects { afterEvaluate { project -> if (project.hasProperty('android')) { project.android { if (namespace == null) { namespace project.group } } } } } }
Error is of missing namespace in the flutter_secure_storage
package. To fix this, update the package to a version that includes the namespace.
Just make sure to replace with the latest compatible version flutter_secure_storage: ^9.2.4
in your pubspec.yaml
file. This simple change should resolve your issue.
I encountered the same error you described while using the flutter_login_facebook
package version 2.0.1. The error you're seeing is likely related to namespace conflicts.
To resolve this, I added the following namespace declaration:
android {
namespace "ru.innim.flutter_login_facebook"
}
This was added to the build.gradle
file of the flutter_login_facebook
module. In my case, the file was located at:
/Users/mac/.pub-cache/hosted/pub.dev/flutter_login_facebook-2.0.1/android/build.gradle
After modifying the build.gradle
file, I performed the following steps:
Remove or comment out the package name from
pubspec.yaml
: This is to ensure a clean slate.Run
flutter clean
: This clears the build artifacts.Add the package name back to
pubspec.yaml
and Runflutter pub get
: This re-installs the package with the namespace fix.Run the Flutter project again: This rebuilds the app with the changes.
This process resolved the error for me without requiring an upgrade of the flutter_login_facebook
package (as there was no update) or reverting to an older Flutter version.
I hope this solution is helpful.