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
<application
...
android:label="${appLabel}"> //OR `android:label=@string/appLabel`
<activity
...
android:label="${appLabel}">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
NOTE: Make sure to change android:label
as well in <activity>
of LAUNCHER
category. If it doesn't require to use android:label
in <activity>
, 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
<string name="appLabel">My App - Development</string>
in app/src/dev/res/values/string.xml
and
<string name="appLabel">My Awesome App</string>
in app/src/prod/res/values/string.xml