Search code examples
androidkotlingradle-kotlin-dsl

Namespace not specified gradle kotlin DSL?


I am using kotlin DSL for build

This is the app level build gradle

plugins {
id("com.android.application")
kotlin("android")
}

android {
namespace = "com.jioads.test"
compileSdk = AppConfig.compile
buildToolsVersion = AppConfig.buildToolsVersion
defaultConfig {
    applicationId = (AppConfig.appId)
    minSdk = AppConfig.minSdk
    targetSdk = AppConfig.target
    versionCode = AppConfig.versionCode
    versionName = AppConfig.versionName

    testInstrumentationRunner = AppConfig.androidTestInstrumentation
}

buildTypes {
    getByName("release") {
        isMinifyEnabled = false
        proguardFiles(
            getDefaultProguardFile("proguard-android-optimize.txt"),
            "proguard-rules.pro"
        )
    }
}
viewBinding {
    android.buildFeatures.viewBinding = true
}
compileOptions {
    sourceCompatibility = JavaVersion.VERSION_1_8
    targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
    jvmTarget = "1.8"
}
}

dependencies {
//std lib
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
//app libs
implementation(Dependencies.appLibraries)
//test libs
testImplementation(Dependencies.testLibraries)
androidTestImplementation(Dependencies.androidTestLibraries)
implementation(project(":jio-ads-sdk"))
}

AGP version is 8.0.2 Gradle version is 8.0

I am getting the following error

Namespace not specified. Please specify a namespace in the module's build.gradle file like so:

android {
namespace 'com.example.namespace'
}

Solution

  • If ":jio-ads-sdk" is an android module, check whether namespace is specified in the module.