android应用程序的配置文件名称,Android Gradle从strings.xml中读取应用程序名称
我正在尝试为每个构建变体重命名我的APK文件,以包含应用程序名称,versionName,versionCode和内部版本号.到目前为止,除了应用程序名称之外,我的所有工我想使用AndroidManifest.xml文件用于android:label的相同值.这来自字符串资源@ string / app_name.我已经看到了使用以下方法替换资源值的能力:resValue "string", "a
我正在尝试为每个构建变体重命名我的APK文件,以包含应用程序名称,versionName,versionCode和内部版本号.到目前为止,除了应用程序名称之外,我的所有工
我想使用AndroidManifest.xml文件用于android:label的相同值.这来自字符串资源@ string / app_name.我已经看到了使用以下方法替换资源值的能力:
resValue "string", "app_name", "Some new value"
但我只想读取此值并使用它来命名我的APK文件.
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
renameApk(variant, output)
}
}
def renameApk(variant, output) {
def apkPath = output.outputFile.parent
def baseName = project.archivesBaseName
baseName += "-${variant.buildType.name}"
// add version name and version code
baseName += "-v${variant.mergedFlavor.versionName}-${variant.mergedFlavor.versionCode}"
// if built on jenkins ci, add jenkins build number:
def buildNumber = System.getenv('BUILD_NUMBER')
if (buildNumber && buildNumber.size() > 0) {
baseName += "-b${buildNumber}"
}
// if the variant will not be zipAligned, specify that
if (!output.zipAlign) {
baseName += '-unaligned'
}
// set the output file
output.outputFile = new File(apkPath, "${baseName}.apk");
}
更多推荐
所有评论(0)