SimformSolutionsPvtLtd / flutter_credit_card

A credit card widget for Flutter application.
https://pub.dev/packages/flutter_credit_card
MIT License
417 stars 241 forks source link

Project build Android Gradle lacking the namespace #162

Open davemg3 opened 7 months ago

davemg3 commented 7 months ago
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")
     }
navaidali commented 6 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.

BUILD FAILED in 1s Error: Gradle task assembleDebug failed with exit code 1

navaidali commented 6 months ago
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???

davemg3 commented 6 months ago

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

gapkalov commented 2 days ago

just apply PR https://github.com/SimformSolutionsPvtLtd/flutter_credit_card/pull/171