一个Android Studio工程根据网址打包出不同的apk

0、更改配置build.gradle(app)

android {
.......
.......
productFlavors {
        two_main{
            // 设置applicationId(这里很重要,两个相同applicationId的apk不同同时安装在同一台Android手机中)
            applicationId "com.onedream.twogamemain.two_main"
            // 自动生成@string/app_name为demo
            resValue "string","app_name","双塞主"
            // 自动生成@string/app_name为demo
            resValue "string","web_api","网址1"
        }
        two_secondary{
            // 设置applicationId(这里很重要,两个相同applicationId的apk不同同时安装在同一台Android手机中)
            applicationId "com.onedream.twogamemain.two_secondary"
            resValue "string","app_name","双塞副"
            resValue "string","web_api","网址2"
        }

        three_main{
            // 设置applicationId(这里很重要,两个相同applicationId的apk不同同时安装在同一台Android手机中)
            applicationId "com.onedream.twogamemain.three_main"
            resValue "string","app_name","三塞主"
            resValue "string","web_api","网址3"
        }
        three_secondary{
            // 设置applicationId(这里很重要,两个相同applicationId的apk不同同时安装在同一台Android手机中)
            applicationId "com.onedream.twogamemain.three_secondary"
            resValue "string","app_name","三塞副"
            resValue "string","web_api","网址4"
        }
    }

    //必须要保证所有的flavor 都属于同一个维度
    flavorDimensions "default"

    lintOptions {
        checkReleaseBuilds false
        abortOnError false
    }
}

1、strings.xml文件注释掉app_name和web_api


   

你可能感兴趣的:(一个Android Studio工程根据网址打包出不同的apk)