flutter_compass icon indicating copy to clipboard operation
flutter_compass copied to clipboard

Causes build failure for Android

Open karatekid430 opened this issue 1 year ago • 15 comments

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.

karatekid430 avatar Sep 30 '24 17:09 karatekid430

yes, an error occurs

TheHasnatBD avatar Oct 04 '24 02:10 TheHasnatBD

We would also greatly appreciate this being resolved ❤️

PlayCulture avatar Oct 06 '24 23:10 PlayCulture

Looking at this, best we use the Android namespace name

namespace "com.hemanthraj.fluttercompass"

karatekid430 avatar Oct 11 '24 03:10 karatekid430

https://github.com/hemanthrajv/flutter_compass/pull/116

Looks resolved. But I do not see a release.

karatekid430 avatar Oct 11 '24 03:10 karatekid430

@hemanthrajv pls

IldySilva avatar Oct 12 '24 12:10 IldySilva

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

benneca avatar Oct 18 '24 20:10 benneca

update it, please

AndRud avatar Oct 23 '24 18:10 AndRud

thank you, this helped!

Ricky2118 avatar Oct 24 '24 02:10 Ricky2118

When will this be released?

nukithelegend avatar Oct 25 '24 06:10 nukithelegend

@xVemu please fix this

mithun-itspe avatar Oct 29 '24 17:10 mithun-itspe

@xVemu please fix this

I'm not owner of the repo

xVemu avatar Oct 29 '24 17:10 xVemu

@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."
                }
            }
        }
    }
}

Rob-Biemans avatar Oct 30 '24 06:10 Rob-Biemans

Please make a new release with the namespace attribute

dominolog avatar Oct 30 '24 09:10 dominolog

please merge!

larsien avatar Nov 07 '24 14:11 larsien

please merge

DmitriySimonov avatar Nov 14 '24 12:11 DmitriySimonov

This can be closed

xVemu avatar Mar 06 '25 09:03 xVemu