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