如何使用香精在Android的工作室不同的应用程序的名称? [英] How to use flavors with different app names in Android studio?
问题描述
在我的应用程序级build.gradle我有以下形式:
In my app-level build.gradle I have the following flavors:
productFlavors {
originalFlavour{
}
freeFlavour{
}
}
事情正在建设两个口味,我得到了相同的应用程序名称。相反,我想对每个不同的口味应用程序的名称。刚添加后缀将是有益的。希望有人能帮助我。
The thing is building both flavors I get the same App Name. Instead I would like to have different app names for each flavors. Just adding a suffix would be useful. Hope someone could help me.
在此先感谢
修改
应用程序/ src目录/主/ AndroidManifest.xml中
app/src/main/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="z.fncapps.etsiipod" >
<uses-permission
android:name="android.permission.CALL_PHONE"
android:required="false" />
<uses-feature
android:name="android.hardware.telephony"
android:required="false"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<!-- actvities declared here -->
</application>
</manifest>
应用程序/ src目录/ freeFlavour / AndroidManifest.xml中
app/src/freeFlavour/AndroidManifest.xml
<uses-permission
android:name="android.permission.CALL_PHONE"
android:required="false" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-feature
android:name="android.hardware.telephony"
android:required="false" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<!-- actvities declared here -->
</application>
推荐答案
从现有的strings.xml $ c取出
APP_NAME
字符串$ C>文件,那么你可以这样做:
Remove the app_name
string from your existing strings.xml
file, then you can do this:
productFlavors {
originalFlavour{
resValue "string", "app_name", "Original Flavor Name"
}
freeFlavour{
resValue "string", "app_name", "Free Flavor Name"
}
}
那么现有引用 @字符串/ APP_NAME
在你的清单将引用生成的字符串资源,它是基于风味选择。
Then the existing reference to @string/app_name
in your manifest will refer to a generated string resource, which is based on the flavor selected.
请注意,如果您指定为您推出的活动标签(通过定义安卓:在
元素),该值将被用在许多用户可见的地方,而不是你的应用程序的标签。为了克服这个为你的情况,你可以从取下标签的&LT标签
XML标记;活性GT; &LT;活性GT;
元素完全。请参见 http://stackoverflow.com/a/13200774/2911458 对这种区别的更多细节。
Note that if you specify a label for your launch Activity (by defining the android:label
xml tag in the <activity>
element), that value will be used in many user-visible places rather than your application's label. To overcome this for your case, you can just remove the label from your <activity>
element altogether. See http://stackoverflow.com/a/13200774/2911458 for more details on this distinction.
这篇关于如何使用香精在Android的工作室不同的应用程序的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!