1、在app的build.gradle中添加
flavorDimensions "version" productFlavors { // app1 app1 { // 设置applicationId(这里很重要,两个相同applicationId的apk不同同时安装在同一台Android手机中) applicationId "com.example.myapplicationa" // 自动生成@string/app_name为demo resValue "string", "app_name", "雷神" // 定义app_icon字段,在AndroidManifest.xml文件中用到 manifestPlaceholders = [app_icon: "@drawable/touxiang2"] buildConfigField "int", "TYPE", "1" } // app2 app2 { // 解释同app1 applicationId "com.example.myapplicationa1" resValue "string", "app_name", "雷神1" manifestPlaceholders = [app_icon: "@drawable/touxiang2"] buildConfigField "int", "TYPE", "2" } } lintOptions { checkReleaseBuilds false abortOnError false }修改AndroidManifest.xml文件 android:icon="${app_icon}"