参考文章:
gradle编译完成Copy mapping文件 - 简书 (jianshu.com)
第一步:在app的build.gradle中做如下配置:
android {
android.applicationVariants.all {
variant ->
def buildType = variant.buildType.name
tasks.all {
def mappingDir = "${buildDir}/outputs/mapping/${variant.flavorName}${buildType.capitalize()}"
def mappingPath = "${mappingDir}/mapping.txt"
def mappingFiles = [mappingPath]
def mappingOtherPath = "${rootDir}/outputs/${variant.flavorName}${buildType.capitalize()}"
it.doLast {
copy {
mappingFiles.each {
if (file(it).exists()) {
from it
into mappingOtherPath
}
}
}
}
}
}
}
第二步:生成的mapping目录如下:
第三步:这样生成的mapping.txt可以直接上传到远程仓库,方便线上版本查找问题