Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Causes build failure for Android #117

Open
karatekid430 opened this issue Sep 30, 2024 · 15 comments
Open

Causes build failure for Android #117

karatekid430 opened this issue Sep 30, 2024 · 15 comments

Comments

@karatekid430
Copy link

Please add the required line in the android tag in the build.gradle file:

namespace "compass"

This solves

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ':flutter_compass'.

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.

@TheHasnatBD
Copy link

yes, an error occurs

@PlayCulture
Copy link

We would also greatly appreciate this being resolved ❤️

@karatekid430
Copy link
Author

Looking at this, best we use the Android namespace name

namespace "com.hemanthraj.fluttercompass"

@karatekid430
Copy link
Author

#116

Looks resolved. But I do not see a release.

@IldySilva
Copy link

@hemanthrajv pls

@benneca
Copy link

benneca commented Oct 18, 2024

ditto, all builds using gradle 8 or later require the namespace to be set

@AndRud
Copy link

AndRud commented Oct 23, 2024

update it, please

@Ricky2118
Copy link

thank you, this helped!

tobesucht added a commit to tobesucht/flutter_compass that referenced this issue Oct 24, 2024
Current gradle requires a namespace for each plugin, see: hemanthrajv#117
@nukithelegend
Copy link

When will this be released?

@mithun-itspe
Copy link

@xVemu please fix this

@xVemu
Copy link
Contributor

xVemu commented Oct 29, 2024

@xVemu please fix this

I'm not owner of the repo

@Rob-Biemans
Copy link

Rob-Biemans commented Oct 30, 2024

@karatekid430 @mithun-itspe @IldySilva @nukithelegend @xVemu

You can also add the following to the build.gradle file located in /android/build.gradle;

// ADD: first line of the build.gradle file:
import groovy.xml.XmlSlurper

// after line: rootProject.buildDir = '../build'
subprojects { project ->
    afterEvaluate {
        if (project.plugins.hasPlugin('com.android.application') || project.plugins.hasPlugin('com.android.library')) {
            // fix AAPT: error: resource android:attr/lStar not found.
            project.android {
                compileSdkVersion 34
                buildToolsVersion "34.0.0"
            }

            if (!project.android.hasProperty('namespace') || project.android.namespace == null || project.android.namespace.isEmpty()) {
                def manifestFile = project.file("src/main/AndroidManifest.xml")
                if (manifestFile.exists()) {
                    def manifest = new XmlSlurper().parse(manifestFile)
                    def packageName = [email protected]()
                    if (packageName) {
                        project.android.namespace = packageName
                        println "Setting namespace for ${project.name} from AndroidManifest.xml: ${packageName}"
                    } else {
                        println "Warning: Could not set namespace for ${project.name} as package name is missing in AndroidManifest.xml."
                    }
                } else {
                    println "Warning: AndroidManifest.xml not found in ${project.name}. Cannot set namespace."
                }
            }
        }
    }
}

@dominolog
Copy link

Please make a new release with the namespace attribute

@larsien
Copy link

larsien commented Nov 7, 2024

please merge!

@DmitriySimonov
Copy link

please merge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests