[플러터] Warning: Mapping new ns ~ to old ns ~ 해결 방법

개요

기존 소스코드 분석 위주로 플러터 개발을 진행하다 보니 예제 하나를 실행해보려 해도 깔끔하게 진행되는 법이 없습니다. 개발환경이 제 각각 다르고 안드로이드 스튜디오가 업데이트 되면서 gradle 또한 호환성을 갖는 버전으로 업데이트 해주면서 맞춰주어야 하는데 그러지 못함에서 나타나는 오류와 경고들이 많이 보입니다. 

 

 

 

아래 경고 메시지 Warning: Mapping new ns ~ to old ns ~ 의 경우 gradle 버전이 낮아서 나타나는 경고 메시지입니다. 궂이 경고를 없애지 않아도 앱 실행은 정상적으로 되는 것을 확인했는데 깔끔한 처리를 위해 경고 메시지를 없애도록 gradle 버전을 올려보겠습니다.

 

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

 

 

해결책

 

android/build.gradle 파일 내 gradle 버전을 올려주고, 

android/gradle/wrapper/gradle-wrapper.propertis 파일 내 gradle URL 을 버전에 맞게 변경해줍니다.

# android/build.gradle 파일 

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

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


android/build.gradle 파일 내 gradle 버전을 올려줍니다.



# android/gradle/wrapper/gradle-wrapper.propertis 파일

distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.2-all.zip

 

 

저는 7.1.2 버전으로 올렸는데 2022년 12월 기준 7.4.0 버전이 나왔고 이후 마이너 업그레이드도 계속 진행되고 있다고 하니 본인 개발 환경에 맞는 버전으로 올리시는 걸 추천드립니다.

 

 

마무리

책 한권 독파하고 플러터 개발을 시작해보려 했으나 엄두가 안나서 책을 더 봐야 생각했지만 책을 더 사면 곤란하겠다 싶은게 책의 내용은 거기서 거기이고 예제 코드를 돌려보는 환경이 너무 빨리 변하는 듯 해요. 그래서 완성된 코드를 보고 리버스 엔지니어링 방식으로 지식을 습득하기로 했습니다. 그런데 이런 오류 때문에 막힘이 발생해서 스트레스네요.

 

 

안드로이드 스튜디오 버전업과 맞추어 dart, gradle 등 함께 버전업되어야 하는 사항들이 많이 있는듯 합니다. Android Gradle 플러그인 출시 노트 페이지를 참고해서 주기적으로 앱 호환성에 문제가 없는지 체크해서 사전에 문제가 발생하지 않도록 해야 겠습니다.

 

https://developer.android.com/studio/releases/gradle-plugin?hl=ko 

 

Android Gradle 플러그인 출시 노트  |  Android 개발자  |  Android Developers

Android 스튜디오 빌드 시스템은 Gradle을 기반으로 하며 Android Gradle 플러그인에는 Android 앱을 빌드하는 데 사용하는 몇 가지 추가 기능이 있습니다.

developer.android.com