From d8a8f87082a5ffa00f65af5b1b6e24d5dba045c4 Mon Sep 17 00:00:00 2001 From: tamslo Date: Wed, 13 Nov 2024 19:11:13 +0100 Subject: [PATCH] build(app): add missing Android namespace attributes of dependencies --- app/android/build.gradle | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/app/android/build.gradle b/app/android/build.gradle index aca8b4a2..84072683 100644 --- a/app/android/build.gradle +++ b/app/android/build.gradle @@ -18,6 +18,34 @@ allprojects { } } +// From https://medium.com/@vortj/solving-namespace-errors-in-flutters-android-gradle-configuration-c2baa6262f8b +subprojects { + afterEvaluate { project -> + if (project.hasProperty('android')) { + project.android { + if (namespace == null) { + namespace = project.group.toString() // Set namespace as fallback + } + project.tasks.whenTaskAdded { task -> + if (task.name.contains('processDebugManifest') || task.name.contains('processReleaseManifest')) { + task.doFirst { + File manifestFile = file("${projectDir}/src/main/AndroidManifest.xml") + if (manifestFile.exists()) { + String manifestContent = manifestFile.text + if (manifestContent.contains('package=')) { + manifestContent = manifestContent.replaceAll(/package="[^"]*"/, "") + manifestFile.write(manifestContent) + println "Removed 'package' attribute from ${manifestFile}" + } + } + } + } + } + } + } + } +} + rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}"