How To Fix [Error] Warning: Mapping new ns lines are printed in the logs during gradlew

Error:

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/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/sys-img2/02 to old ns http://schemas.android.com/sdk/android/repo/sys-img2/01  

Solution 1 :

1. To solve the Mapping error, First we have to Open Your_Flutter_App -> android -> build.gradle file and text editor. I’m using Visual Studio Code editor. Now go inside dependencies block in buildscript and Here you have to update your old build Gradle to new com.android.tools.build:gradle:7.0.2.

Source Code of My build.gradle file after updating :


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

    dependencies {
        classpath 'com.android.tools.build:gradle:7.0.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

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

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

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

2. Now we have to also update Gradle distributionUrl in Your_Flutter_Project -> android -> gradle -> wrapper -> gradle-wrapper.properties file. So open this file and put new Gradle URL https\://services.gradle.org/distributions/gradle-7.2-all.zip .

Source Code of My gradle-wrapper.properties file after updating :

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip

3. Now the main part, We have to clean our flutter project build and rebuilt it again. So open your flutter project Root directory in CMD or Terminal and execute the flutter clean command.

4. Now you are good to go. All you have to do is run your flutter project with the flutter run command and you will see that the error is gone.

Solution 2 :

Change the compileSdkVersion and targetSdkVersion

Example:

android {
    compileSdkVersion 31

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.nucleio.driver"
        minSdkVersion 20
        targetSdkVersion 31
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }
}

Reduce it with 1

android {
    compileSdkVersion 30

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        applicationId "com.nucleio.driver"
        minSdkVersion 20
        targetSdkVersion 30
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        multiDexEnabled true
    }
}

Leave a Comment

Your email address will not be published. Required fields are marked *