Tealium / tealium-flutter

Tealium Flutter Plugin
Other
6 stars 6 forks source link

Namespace not specified #43

Open sooslevi9 opened 2 months ago

sooslevi9 commented 2 months ago

tealium: ^2.5.0

1: Task failed with an exception.

2: Task failed with an exception.

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

image

android/build.gradle

`buildscript { ext.kotlin_version = '1.9.23' repositories { google() mavenCentral() }

dependencies {
    classpath 'com.android.tools.build:gradle:8.5.1'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

}

allprojects { repositories { google() mavenCentral() } }

rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') }

tasks.register("clean", Delete) { delete rootProject.buildDir } `

tamayok commented 1 month ago

@sooslevi9 thanks for opening this. We'll take a look at it, and let you know what's going on.

michalkos commented 1 month ago

This is blocking issue, when using AGP 8. Any resolution?

jameskeith commented 1 month ago

@michalkos @sooslevi9 Thanks for your patience on this one - we've just published updates to all the packages that we support, since they all suffered the same issue as the main tealium package.

I'm afraid it took a while to verify support across a wide range of Android/AGP versions which we look to maintain, so we've pulled in some additional changes present in the newer Flutter plugin templates to hopefully make these packages more reliable going forward.

In case it's useful for you or anyone else reading this, most issues of this nature can be worked-around in Gradle. For example, in this instance, since the tealium package creates it's own module in your Android Studio project, those missing requirements can be set from root project's build.gradle:

allprojects {
    // repositories omitted ...

    subprojects {
        afterEvaluate { project ->
            if (project.name == "tealium" && project.hasProperty("android")) {
                project.android {
                    if (project.android.hasProperty("namespace") && project.android.namespace == null) {
                        namespace = 'com.tealium'
                    }
                    // set any other required fields e.g.
                    buildFeatures {
                        buildConfig true
                    }
                }
            }
        }
    }
}

I'll also note/concede that this isn't gradle best-practice - it's definitely a workaround.

Please let me know how you get on with the latest versions.