I am trying to figure out a way to be able to change my application\'s app name per build type in gradle.
For instance, I would like the debug version to have
There are multiple ways you can do.
you can create manifestPlaceholders OR resValue in app level build.gradle. e.g.
buildTypes {
release {
...
manifestPlaceholders = [appLabel: "My App"]
//resValue "string", "appLabel", '"My App"'
}
debug {
...
manifestPlaceholders = [appLabel: "My App - Debug"]
//resValue "string", "appLabel", '"My App - Debug"'
}
}
OR
If you have productFlavors, you can create there
flavorDimensions "env"
productFlavors {
dev {
dimension "env"
...
manifestPlaceholders = [appLabel: "My App - Development"]
//resValue "string", "appLabel", '"My App - Development"'
}
prod {
dimension "env"
...
manifestPlaceholders = [appLabel: "My Awesome App"]
//resValue "string", "appLabel", '"My Awesome App"'
}
}
Then in AndroidManifest.xml if you are using manifestPlaceholders, just change android:label="${appLabel}" as below OR if you are using resValue, just change android:label=@string/appLabel
//OR `android:label=@string/appLabel`
NOTE: Make sure to change android:lable as well in of LAUNCHER category. If it doesn't require to use android:label in , just remove this.
If you do not want to add in build.gradle directly, you can add in values/string.xml of selected ProductFlavors. e.g.
Add
My App - Development
in app/src/dev/res/values/string.xml
and
My Awesome App
in app/src/prod/res/values/string.xml