Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

android - How to change app name per Gradle build type

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 <APP_NAME>-debug and the qa version to have <APP-NAME>-QA.

I am familiar with:

debug {
        applicationIdSuffix '.debug'
        versionNameSuffix '-DEBUG'
}

However, I can't seem to find a gradle command to apply the change of the app when in the launcher.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If by "app name", you mean android:label on <application>, the simplest solution is to have that point at a string resource (e.g., android:label="@string/app_name"), then have a different version of that string resource in a src/debug/ sourceset.

You can see that in this sample project, where I have a replacement for app_name in src/debug/res/values/strings.xml, which will be applied for debug builds. release builds will use the version of app_name in src/main/.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...