AndroidStudio中的gradle多渠道打包

1.在项目下的build.gradl配置渠道

1.普通版

//android studio  3.0之后才有(才需要加这个flavorDimensions "default")

flavorDimensions "default"

productFlavors {

    baidu {

        manifestPlaceholders = [CHANNEL_KEY:"baidu"]

    }

    huawei {

        manifestPlaceholders = [CHANNEL_KEY:"huawei"]

    }

    xiaomi {

        manifestPlaceholders = [CHANNEL_KEY:"xiaomi"]

    }

    googleplay {

        manifestPlaceholders = [CHANNEL_KEY:"googleplay"]

    }

    wandoujia {

        manifestPlaceholders = [CHANNEL_KEY:"wandoujia"]

    }

}

2.升级版

//android studio  3.0之后才有(才有加flavorDimensions "default")

flavorDimensions "default"

productFlavors {

m360 {

        }

        googleplay {

        }

        xiaomi {

        }

        lenove {

        }

        huawei {

        }

        gfan {

        }

}

productFlavors.all {

        flavor -> flavor.manifestPlaceholders = [CHANNEL_KEY: name]

}


2.在菜单栏Build下Generate Signed APK,输入密码,next...next...

你可能感兴趣的:(AndroidStudio中的gradle多渠道打包)