I am looking to generate a second debug.apk in a different file location within the project path. Is it possible to create a second file path location for the .apk build within gradle?
The current build path is:
C:..appbuildoutputsapkdebugdebug.apk
I would like to create a second apk location after the build, for example:
C:..appdebug_apkdebug.apk
I am currently changing the names of the output files in gradle with:
applicationVariants.all { variant ->
variant.outputs.all { output ->
def appVersionName = "company_name_${versionName}"
switch (buildType.name) {
case "debug": {
outputFileName = "${appVersionName}_debug.apk"
break
}
case "release": {
outputFileName = "${appVersionName}_release.apk"
break
}
}
}
}
2
Answers
This code is combination from this resource and this answer
Here’s an app module build script that provides the following:
copy*Apk
task that collects the APK for each build variant.copyApks
task that collects the APKs for all build variants.assemble*
tasks to also collect their specific APKs.build.gradle.kts
build.gradle
If you’re using Groovy these are the lines that would be different:
Usage
Result
Differences
clean
task doesn’t delete the collected APKs.