Solve WARNING: MAPPING NEW NS TO OLD NS in Flutter

Ahmadreza Shamimi
2 min readApr 7, 2023

--

Greetings, Flutter Developer. If you’re reading this, it’s likely that you’ve encountered a warning message regarding the mapping of new namespace to old namespace after updating to Flutter SDK 2.10. This warning appears as a red alert, even though your project should still function properly. Fortunately, I have identified a solution for this problem, which involves migrating from an older version of Gradle to the latest version in your Android Native projects.

Error: Mapping new ns to old ns

Launching lib\main.dart on ONEPLUS A6010 in debug mode...
Running Gradle task 'assembleDebug'...
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01
Warning: Mapping new ns http://schemas.android.com/repository/android/generic/02 to old ns http://schemas.android.com/repository/android/generic/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/02 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/addon2/03 to old ns http://schemas.android.com/sdk/android/repo/addon2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/02 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/repository2/03 to old ns http://schemas.android.com/sdk/android/repo/repository2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: Mapping new ns http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01
Warning: unexpected element (uri:"", local:"base-extension"). Expected elements are <{}codename>,<{}layoutlib>,<{}api-leve

1. Clean your project

Run flutter clean command and make sure <project>/build folder and <project>/android/build is deleted.

2. Update gradle.properties

Got to gradle-wrapper.properties file located at <project>/android/gradle , then set value to distributionUrl to whatever latest gradle distribution is available, https\://services.gradle.org/distributions/gradle-7.6-bin.zip

#Wed Feb 16 23:35:26 IST 2022
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

3. Update project build.gradle

Update your android build.gradle file located at <project>/android/build.gradle with new version of Gradle and Kotlin available at this time.

classpath 'com.android.tools.build:gradle:7.4.1' and ext.kotlin_version = '1.8.20'

https://developer.android.com/build/releases/gradle-plugin#kts

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

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

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

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

task clean(type: Delete) {
delete rootProject.buildDir
}

4. Final Step

After running “flutter packages get”, launch your flutter app. Please note that the initial launch may take longer as the IDE downloads new files. We appreciate you taking the time to read our tutorial and hope it was helpful to you.

--

--

Ahmadreza Shamimi
Ahmadreza Shamimi

Written by Ahmadreza Shamimi

I'm Ahmadreza Shamimi with an experienced with over 10 years of experience coding with web and mobile platforms.

Responses (1)