Android一个项目,打包成不同的包,并在同一设备运行

来源:互联网 发布:单片机usb协议 编辑:程序博客网 时间:2024/06/06 05:49

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必须添加

阅读全文
2 0