Open davemg3 opened 7 months ago
Having same issue, the namespace is already set in build.gradle but getting this error after adding flutter_credit_card widget.
FAILURE: Build failed with an exception.
What went wrong: A problem occurred configuring project ':flutter_credit_card'.
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.com/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.com/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.org
BUILD FAILED in 1s Error: Gradle task assembleDebug failed with exit code 1
A problem occurred configuring project ':flutter_credit_card'. > 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.com/r/tools/upgrade-assistant/set-namespace for information about setting the namespace.
This error occurs after Android Gradle Plugin updated >= 8.x.x. To get rid of error use following method:
In your build.gradle you can conditionally set the namespace using the following:
android { ... if (project.android.hasProperty("namespace")) { namespace("change.this.to.your.namespace") }
This solution didn't work. I have integrated credit card in my project. The namespace of the project is already in the build.gradle, why should I add "flutter_credit_card" as a name space???
As you said you added a namespace for your project but not for the library. If the libray dev has included the namespace in his package, you dont have too but if it is missing (which is the case here) you can set a namespace by writing following in android/buid.gradle :
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
afterEvaluate { project ->
if (project.hasProperty('android')) {
project.android {
if (namespace == null) {
namespace project.group
}
}
}
}
}
subprojects {
project.evaluationDependsOn(':app')
}
My first message was for the developper of the library so as he can update his package
This error occurs after Android Gradle Plugin updated >= 8.x.x. To get rid of error use following method:
In your build.gradle you can conditionally set the namespace using the following: