Reputation: 937
I have my bluid.gradle
set different app_names for debug and release like this:
buildTypes {
debug {
...
resValue "string", "app_name", "App Dev"
}
release {
...
resValue "string", "app_name", "App"
}
}
Now, I want to add two flavors for two different targets of the app:
buildTypes {
debug {
...
resValue "string", "app_name", "App Dev"
}
release {
...
resValue "string", "app_name", "App"
}
}
productFlavors {
app {
...
resValue "string", "app_name", "App"
}
client {
...
resValue "string", "app_name", "Client App"
}
}
The question is, how can I set the app_name to match this output:
I have seen some answers using resources, but I want to know if there is a way to do so just using gradle.
Upvotes: 1
Views: 1554
Reputation: 11
just like this
build.gradle:
buildTypes {
debug {
minifyEnabled false
manifestPlaceholders = [app_name : "@string/app_name_debug_version"
, app_icon : "@mipmap/ic_launcher_debug"
]
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
debuggable false
manifestPlaceholders = [app_name : "@string/app_name"
, app_icon : "@mipmap/ic_launcher"
]
}
}
productFlavors {
client {}
app {}
}
AndroidManifest.xml :
<application
android:name=".common.base.App"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="${app_icon}"
android:label="${app_name}"
android:largeHeap="true"
android:theme="@style/AppTheme"
tools:replace="android:label,android:icon">
Upvotes: 1
Reputation: 21
You can do something like this:
flavorDimensions "roadmap"
productFlavors{
production {
dimension "roadmap"
applicationId "com.yourappid"
versionCode 1
versionName "0.1.0"
}
preview {
dimension "roadmap"
applicationIdSuffix ".beta"
versionNameSuffix "-beta"
versionCode 1
versionName "0.1.0"
}
demo {
dimension "roadmap"
applicationIdSuffix ".alpha"
versionNameSuffix "-alpha"
versionCode 1
versionName "0.1.0"
}
Upvotes: 0
Reputation: 698
Try this
flavorDimensions "stage", "production"
fav1Debug {
dimension "stage"
resValue "string", "app_name", "App Debug"
}
fav1Production {
dimension "production"
resValue "string", "app_name", "App Production"
}
fav2Debug {
dimension "stage"
resValue "string", "app_name", "Client Debug"
}
fav2Production {
dimension "production"
resValue "string", "app_name", "Client Production"
}
Upvotes: 1
Reputation: 698
You can make use of app_name in AndroidManifest.xml file for Launcher activity like
<activity
android:name="com.aone.adesa.Main.SplashScreenActivity"
android:configChanges="orientation|screenSize"
android:label="@string/app_name"
</activity
Upvotes: 0