1.在開發(fā)過程中會有多個平臺不同包名的打包需求复凳,這里記錄一下使用Gradle來進(jìn)行分包操作的筆記。
productFlavors {
googleplay_A {
applicationId "com.demo.demoA"
versionName '1.1.2'
buildConfigField("int", "APP_TYPE", "0")
buildConfigField("int", "UNIT_TYPE", "0")
buildConfigField("int", "APP_LOCATION", "0")
manifestPlaceholders = [APP_ICON: "@mipmap/ic_launcher"]
resValue "string", "app_name", "EasyTouch"
}
googleplay_B {
applicationId "com.demo.demoB"
versionName '1.1.2'
buildConfigField("int", "APP_TYPE", "0")
buildConfigField("int", "UNIT_TYPE", "1")
buildConfigField("int", "APP_LOCATION", "0")
manifestPlaceholders = [APP_ICON: "@mipmap/ic_launcher"]
resValue "string", "app_name", "EasyTouch"
}
2.對于不同的包需要使用到不同的屬性是越,有如下方式:
2.1 buildConfigField("int", "APP_TYPE", "0")
使用Build參數(shù)耳舅,代碼中使用如下:
int appType=BuildConfig.APP_TYPE;
2.2 manifestPlaceholders = [APP_ICON: "@mipmap/ic_launcher"]
使用替代符,使用在XML中倚评。使用如下:
<application
android:largeHeap="true"
android:name=".MyApplication"
android:allowBackup="true"
android:icon="${APP_ICON}"
android:label="@string/app_name"
android:persistent="true"
android:supportsRtl="true"
android:theme="@style/AppTheme">