How to get the project name in build.gradle in android studio?
buildTypes {
release {
applicationVariants.all { variant ->
variant.outputs.each { output -> String projectName = project.name
}
}
}
}
CodePudding user response:
buildTypes {
release {
applicationVariants.all { variant ->
variant.outputs.each { output -> String projectName = getRootProject().name
}
}
}
CodePudding user response:
app-release.apk can be replaced by your-project-name.apk
buildTypes {
release {
applicationVariants.all { variant ->
variant.outputs.each { output -> String projectName = getRootProject().name
output.outputFileName = projectName ".apk"
}
}
OR
buildTypes {
release {
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFileName = getRootProject().name ".apk"
}
}