软件编程
位置:首页>> 软件编程>> Android编程>> Android编译出现Warning:Mapping new ns to old ns报错的解决方案

Android编译出现Warning:Mapping new ns to old ns报错的解决方案

作者:旺仔大牛  发布时间:2022-08-19 02:37:29 

标签:android,编译,warning

出现场景

更新了Android Studio版本后,运行项目就出现以下警告。

Android编译出现Warning:Mapping new ns to old ns报错的解决方案

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

查资料说是Gradle版本的问题,于是尝试将Gradle和AGP升级到最新版。

解决方案

更新Gradle和AGP可以手动更改,但是推荐使用工具自动升级,因为AGP的版本必须和Gradle的版本保持对应关系,工具会自动保持对应的版本。

打开Tools菜单,选择最下面的AGP Upgrade Assistant.

Android编译出现Warning:Mapping new ns to old ns报错的解决方案

会弹出以下的界面,点击 Run selected steps,就会自动开始升级Gradle和Android Gradle Plugin版本。

Android编译出现Warning:Mapping new ns to old ns报错的解决方案

等待升级完成

Android编译出现Warning:Mapping new ns to old ns报错的解决方案

出现以上提示就说明升级版本成功啦。

我们可以查看gradle的版本和AGP版本已经被更新到最新的版本。
gradle/wrapper/gradle-wrapper.properties

#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
# gradle最新版本
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip

build.gradle

buildscript {
   ext.kotlin_version = '1.6.21'
   repositories {
.....
   }

dependencies {
       // AGP版本
       classpath 'com.android.tools.build:gradle:7.1.3'
       classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
   }
}

重新编译项目,就不会出现警告了。

来源:https://blog.csdn.net/adojayfan/article/details/125317683

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com