Android build warning Mapping new ns to old ns

AndroidBuildbuild.gradleWarnings

Android Problem Overview


I created a new project in android studio and added all the dependencies. All of them are latest. When I built the project I am getting these warnings. There is no code in the app. These started showing after I added the dependencies.

Should I just leave it like this?

Sync output

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
}

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.3"

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

dependencies {

    def version_nav = "2.3.4"
    def lifecycle_version = "2.3.0"
    def version_retrofit_coroutines_adapter = "0.9.2"
    def version_kotlin_coroutines = "1.3.9"
    def version_moshi = "1.9.2"
    def retrofit ="2.9.0"
    def hilt_version = "2.31-alpha"
    def hilt_viewmodels = "1.0.0-alpha03"
    def fragment_ktx = "1.3.1"
    def okhttp = "4.9.0"
    def moshi_converter = "2.8.1"
    def recycler_view_version = "1.2.0-beta02"
    def timber_version = "4.7.1"
    def java_poet_version = "1.13.0"
    def coil_version = "1.1.1"


    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'

    // Timber
    implementation "com.jakewharton.timber:timber:$timber_version"

    implementation "com.squareup.retrofit2:retrofit:$retrofit"
    implementation "com.squareup.retrofit2:converter-gson:$retrofit"

    // Moshi
    implementation "com.squareup.moshi:moshi:$version_moshi"
    implementation "com.squareup.moshi:moshi-kotlin:$version_moshi"
    implementation "com.squareup.retrofit2:converter-moshi:$moshi_converter"

    // Navigation
    implementation "androidx.navigation:navigation-fragment-ktx:$version_nav"
    implementation "androidx.navigation:navigation-ui-ktx:$version_nav"

    // Coroutines
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version_kotlin_coroutines"
    implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$version_kotlin_coroutines"

    // Retrofit Coroutines Support
    implementation "com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:$version_retrofit_coroutines_adapter"

    //RecyclerView
    implementation "androidx.recyclerview:recyclerview:$recycler_view_version"

    // ViewModel
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    // LiveData
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
    // Lifecycle only (without ViewModel or LiveData)
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"

    //OkHttp3
    implementation"com.squareup.okhttp3:okhttp:$okhttp"

    //Hilt
    implementation "com.google.dagger:hilt-android:$hilt_version"
    kapt "com.google.dagger:hilt-android-compiler:$hilt_version"

    //Hilt View models
    implementation "androidx.hilt:hilt-lifecycle-viewmodel:$hilt_viewmodels"
    kapt "androidx.hilt:hilt-compiler:$hilt_viewmodels"

    //Fragments
    implementation "androidx.fragment:fragment-ktx:$fragment_ktx"

    //Java Poet
    kapt "com.squareup:javapoet:$java_poet_version"

    //Coil
    implementation "io.coil-kt:coil:$coil_version"

}

kapt {
    correctErrorTypes true
}

The app is run without any issues but since this is a warning I have seen first time. I couldn't find anything related anywhere else, wanted to know why this is happening.

Android Solutions


Solution 1 - Android

I had the same issue and turned out that the buildToolsVersion "30.0.3" used is not installed, so I switched to the installed buildToolsVersion "29.0.3" (in my case) and the warning disappeared.

Solution 2 - Android

I'm using Android Studio Arctic Fox (2020.3.1,Patch) which point the buildToolsVersion "30.0.2" and got the same error. I fixed it by just update the Android Gradle Plugin version from 4.1.0 to 7.0.2.

image reference

Solution 3 - Android

This happens due to old gradle plugin version.

I did change the SDK version to 31 but my gradle plugin was 4.2. So I was facing this same issue.

To resolve this, Just go to your Project level build.gradle and update the gradle plugin version to the latest one like the following:

buildscript {

// ...

dependencies {
    classpath 'com.android.tools.build:gradle:7.0.2'
}

}

At the time of writing this answer, Gradle 7.0.2 is the latest version.

Solution 4 - Android

I've got a similar error message in VSCode building my Flutter app after upgrading Flutter to version 2.10. The following fixed it for me.

  1. Update all Android SDK packages in Android Studio
  2. In your "..\your_app\android\app\build.gradle" file change compileSdkVersion to 31. If you also want to change your targetSdkVersion to 31, you have to add android:exported="true" or android:exported="false" in your "AndroidManifest.xml" file under activity. What you have to choose and more details on "android:exported" look here android:exported details
  3. In your "..\your_app\android\build.gradle" file change the "ext.kotlin_version" to '1.6.10' and "classpath" of your gradle version to 'com.android.tools.build:gradle:7.0.2'
  4. In your "..\your_app\android\gradle\wrapper\gradle-wrapper.properties" file change the "distributionURL" to https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
  5. Do a flutter clean to delete the old build stuff.

After I have done that, build runs without any error or warning.

Solution 5 - Android

  1. In Android Studio you can also update the Gradle Plugin Version (and the Gradle Version) by going to File > Project Structure. enter image description here

  2. Just go to your Project level build.gradle and update the gradle plugin version to the latest one like the following: dependencies {classpath 'com.android.tools.build:gradle:7.0.2'}.

  3. update gradle-wrapper.properties distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip.

Solution 6 - Android

This helped me:

  1. “Build -> Clean Project”
  2. “File -> Invalidate Caches / Restart” choose “Invalidate and restart option” and close Android Studio

Solution 7 - Android

I installed Android Studio Arctic Fox (2020.3.1) and i started getting that same error on vscode!

> Mapping new ns to old ns blah blah

The FIX for me was to uninstall that version of android studio, install 4.2.2 from here AND download SDK files then update it back to Arctic Fox (from in UI) and issue was gone. I guess its a SDK bug ....

Solution 8 - Android

In my case, invalidating caches and restarting fixed it

Solution 9 - Android

I solved the problem by changing the "Java SDK" in the platform settings. Find it in project structure.

screenshot

Solution 10 - Android

I try this in build.gradle(:app) in android and it make all thing OK:

  compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }

Solution 11 - Android

For Windows

Got to > %LOCALAPPDATA%\Android\Sdk\build-tools

Now leave only one folder, I deleted all except 29.0.3

Restart your system and try again, the error should disappear

Solution 12 - Android

I found a very easy solution of this while developing and Android app (flutter).

Step 1 - Just come in Android SDK manager.(by top right icon near search icon) Step 2 - Uncheck higher level API. (in my case I unchecked API level above 29. if you want to know your max API selection , you can check with this folder name Path - C:\Users\AarifHusain\AppData\Local\Android\Sdk\build-tools\29.0.2 the last folder name 29.0.2 means I have to select SDK platform upto 29 and uncheck higher than 29)

Step 3 - Now apply the changes and let Android studio do its work with network. This process took time depend upon your internet speed after that unzipping take time. after this process if IDE show completion with something error. don't worry its will rectify after restart.

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVishal KashiView Question on Stackoverflow
Solution 1 - AndroidIbrahim HassanView Answer on Stackoverflow
Solution 2 - AndroidWakino ChienView Answer on Stackoverflow
Solution 3 - AndroidParikshit SinghView Answer on Stackoverflow
Solution 4 - AndroidAterusView Answer on Stackoverflow
Solution 5 - AndroidViKi VyasView Answer on Stackoverflow
Solution 6 - AndroidRekssView Answer on Stackoverflow
Solution 7 - AndroidtrinibView Answer on Stackoverflow
Solution 8 - AndroidAsh BaldanView Answer on Stackoverflow
Solution 9 - AndroidAndrey BolshakovView Answer on Stackoverflow
Solution 10 - AndroidbenyaminView Answer on Stackoverflow
Solution 11 - AndroidSubhash ChaudharyView Answer on Stackoverflow
Solution 12 - AndroidAarif HusainView Answer on Stackoverflow