flutterandroid-studionamespacesbuild.gradle

Namespace not specified. Specify a namespace in the module build file


I have worked on a flutter project in 2023. I was facing errors with gradle settings. I managed to migrate the gradle settings following the official Flutter documentation(https://docs.flutter.dev/release/breaking-changes/flutter-gradle-plugin-apply). Now, I am facing another error, highlighted in the attached screenshot. I have specified the namespace as per official documentation(https://developer.android.com/build/configure-app-module#groovy). Is there a way around to fix it?enter image description here


Solution

  • Apparently this is a known issue, this issue occurred in older versions of flutter due to outdated or deprecated packages.

    Possible resolution:

    add the script to android/build.gradle or android/build.gradle.kts:

    subprojects {
       afterEvaluate { project ->
           if (project.hasProperty('android')) {
               project.android {
                   if (namespace == null) {
                       namespace project.group
                   }
               }
           }
       }
    }
    

    If these changes do not solve your problem, read this problem here carefully, I think it will solve your problem.