1.在build.gradle中,与buildTypes同级的目录下
/*打包的配置*/
productFlavors {
gradle1 {
//通过设置不同的appid实现不同APK
applicationId "com.example.administrator.testwechat"
//设置该版本的app名字
manifestPlaceholders = [app_name: "APK1"];
//设置一个标示符,用来区分不同的版本,在代码中使用
//getResources().getString(R.string.type)来获取这个数值,
resValue("string", "type", "in");
}
gradle2 {
applicationId "com.example.administrator.testb"
manifestPlaceholders = [app_name: "APK2"];
//设置一个标示符,用来区分不同的版本
resValue("string", "type", "out");
}
}
2.对于manifest中APK name的处理
tools:replace="label"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="${app_name}"
注意:这个tools:replace必须添加