Best practice for specifying the namespace for dependencies in the gradle file of a flutter app

I am working on fixing an old app for a client that an agency wrote for him. After fixing a few issues and upgrading dependencies, I got stuck in the build process. The main issue is that the namespace of modules that should be dependencies is not specified.

A problem occurred configuring project ':notification_permissions'.

> 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.
> 

I consulted ChatGPT extensively and it suggested to turn the dependency into a module and providing the namespace there. For accessing its build file it suggested to clone the repository and change the gradle file to include the namespace. As I couldn’t imagine that it would make sense to clone repositories of dependencies to manage them myself just to fix a namespace error, I asked for alternatives, and it suggested to fork the repo remotely and maintain it there. I can’t imagine that the best practice is for everyone using the repository to basically fork and maintain it just to manage a namespace issue.

Relevant answers I found (see below) suggested that the issue was with AGP for old gradle versions. However, this is not available in the market place (or doing it automatically) in either Android Studio and IntelliJ. And if I’m on the latest gradle it shouldn’t be an issue, should it? ChatGPT suggests to upgrade manually, which I did, but this doesn’t change anything.

I wonder if I missed something important or my toolchain is messed up.

I am sorry if this sort of question is incorrectly put here as it is more a discussion on best practice instead of a set code / toolchain issue.
These are the respective gradle files if your answer is on a code-level (I am aware that I should switch to declarative style, but I don’t want to conflate issues) with the name of the project replaced by ***; I also appreciate discussion on what is the best overall approach here, as ChatGPTs suggestions seem curious to say the least…

androidappbuild.gradle

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.10'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
    }
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}

apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}

def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}

android {
    namespace '***'
    compileSdkVersion 34

    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }

    defaultConfig {
        applicationId "***"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion 34
        multiDexEnabled true
        versionCode 3
        versionName "1.0.2"
    }

    buildTypes {
        release {
            signingConfig signingConfigs.debug
        }
    }
    compileOptions
            {
                sourceCompatibility JavaVersion.VERSION_17
                targetCompatibility JavaVersion.VERSION_17
            }

    kotlinOptions
            {
                jvmTarget = '17'
            }
}

flutter {
    source '../..'
}

dependencies {
    implementation platform('com.google.firebase:firebase-bom:28.1.0')
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'com.google.firebase:firebase-analytics'
}

androidbuild.gradle

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

    dependencies {
        classpath 'com.android.tools.build:gradle:8.1.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath 'com.google.gms:google-services:4.3.15'
    }
}

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

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

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

androidgradlewrappergradle-wrapper.properties

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

Things I tried:

  • This post (How do I fix ‘namespace not specified’ error in Android Studio?) suggested to upgrade AGP. It doesn’t automatically ask for updating when I specify gradle to an old version (

distributionUrl=https://services.gradle.org/distributions/gradle-7.4-2-bin.zip in gradle-wrapper) and it does not appear in the market place either in intellij or Android Studio and I don’t even get to the run step.

  • This post (Namespace not specified. Specify a namespace in the module’s build file Flutter Android Studio) also refers to AGP and moving the namespace to the build script, which I already did. Adding the compile and kotlin options
  • This post (Namespace not specified. Please specify a namespace in the module’s build.gradle while building flutter application apk) suggests to move the module to the namespace. However, I don’t find the module in the manifest file

Other posts did not address the problem.

flutter doctor showed that all is good (except for VSCode which I don’t use) and I got the latest dependencies (flutter pub get and clean).

New contributor

Simon Johanning is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật