Vishal Kashi
Vishal Kashi

Reputation: 872

Android build warning Mapping new ns to old ns

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.

Upvotes: 69

Views: 105218

Answers (14)

Parikshit Singh
Parikshit Singh

Reputation: 260

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.

Upvotes: 25

SanjuAndroid
SanjuAndroid

Reputation: 11

Android build warning & Error 

1) Android Studio Dolphin 3.1 Patch

distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
classpath 'com.android.tools.build:gradle:7.3.0'
compileSdkVersion 33
android:exported="true"

Error :-
JDK 11 for that
com/android/tools/idea/gradle/run/OutputBuildAction has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Error :-
Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android

==>
Add this line :- 
Android Gradle Plugin Version :- 4.0.2
Gradler Wrapper :- 6.1.1
compileSdkVersion 30

Sdk location - Gradle Jdk  :-  11 version 11.0.17  / jvm 11

Clean and Rebuild it Run

Upvotes: 0

Arun Aditya
Arun Aditya

Reputation: 1104

I was getting this issues while updating my older flutter project older means updating from without null sefty to null sefty version

I added this fix and its working

ext.kotlin_version = '1.6.10'

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

Upvotes: 0

Aterus
Aterus

Reputation: 565

I've got a similar error message in VSCode building my Flutter app after upgrading Flutter to version 3.0. 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.1.2'
  4. In your "..\your_app\android\gradle\wrapper\gradle-wrapper.properties" file change the "distributionURL" to https\://services.gradle.org/distributions/gradle-7.4-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.

Edit: The original post was for Flutter version 2.10. I updated the versions number for Flutter version 3.0

Upvotes: 16

ViKi Vyas
ViKi Vyas

Reputation: 741

  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.

Upvotes: 4

Rekss
Rekss

Reputation: 41

This helped me:

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

Upvotes: 4

Aarif Husain
Aarif Husain

Reputation: 503

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

Upvotes: 0

Subhash Chaudhary
Subhash Chaudhary

Reputation: 39

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

Upvotes: 0

benyamin
benyamin

Reputation: 1

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

  compileOptions {
        sourceCompatibility 1.8
        targetCompatibility 1.8
    }

Upvotes: 0

Andrey Bolshakov
Andrey Bolshakov

Reputation: 1

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

screenshot

Upvotes: 0

Wakino Chien
Wakino Chien

Reputation: 171

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

Upvotes: 17

trinib
trinib

Reputation: 169

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 😕....

Upvotes: 1

Ash Baldan
Ash Baldan

Reputation: 11

In my case, invalidating caches and restarting fixed it

Upvotes: 0

Ibrahim Hassan
Ibrahim Hassan

Reputation: 300

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.

Upvotes: 25

Related Questions