androidkotlinbuild.gradle

Android name space error in building and running in emulator or any real device


# Trying to run application bu it display the name space error already tried with using bundle id and upgrading AGP version.

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

android {
    namespace 'com.example.namespace'
}

If the package attribute is specified in the source AndroidManifest.xml, it can be migrated automatically to the namespace value in the build.gradle file using the AGP Upgrade Assistant; please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.
`

Tried to upgrading and downgrading sdk versions

 defaultConfig {
        applicationId "com.example.namespace"
        minSdkVersion 21
        targetSdkVersion 32
        versionCode 2
        versionName "1.1"
        multiDexEnabled true
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
plugins {
    id 'com.android.application'
    id 'com.google.firebase.crashlytics'
//    id 'com.android.application' version '8.0.3'
//    id 'kotlin-android'
//    id 'kotlin-android-extensions'
//    id 'kotlin-kapt'
}
//apply plugin: 'com.google.gms.google-services'




Solution

  • Add namespace to your module's build.gradle:

    android {
        namespace = "your.namespace.here" // Add your namespace here
        compileSdk = 32
    
        /* Your default config */
        defaultConfig {
            applicationId "com.your.applicationId"
            minSdkVersion 21
            targetSdkVersion 32
            versionCode 2
            versionName "1.1"
            multiDexEnabled true
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
    
        // Others
    }