多渠道共存打包(亖)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_23195583/article/details/53783013

我的工程源代码请点击这里
如果你想要这些包不能共存,那么更改一下gradle就可以了,就相当于渠道包,不过这样的话资源都是main里面的,这里图就不上了,这样的话会覆盖安装。
gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.fanyafeng.codetopackage"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
            applicationVariants.all { variant ->
                variant.outputs.each { output ->
                    def outputFile = output.outputFile
                    if (outputFile != null && outputFile.name.endsWith('.apk')) {
                        def fileName = "${variant.productFlavors[0].name}.apk"
                        output.outputFile = new File(outputFile.parent, fileName)
                    }
                }
            }
        }
    }

    productFlavors {
        z20111308011 {
            applicationId "com.fanyafeng.codetopackage.z20111308011"
            manifestPlaceholders = [APP_NAME: "求福"]
        }
        z20111308016 {
            applicationId "com.fanyafeng.codetopackage.z20111308016"
            manifestPlaceholders = [APP_NAME: "红酒"]
        }
        z20111308069 {
            applicationId "com.fanyafeng.codetopackage.z20111308069"
            manifestPlaceholders = [APP_NAME: "测试"]
        }
        z20111308086 {
            manifestPlaceholders = [APP_NAME: "投融贷"]
        }
        z20111308061 {
            manifestPlaceholders = [APP_NAME: "微寺庙"]
        }
    }


}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'com.android.support:design:25.1.0'
    testCompile 'junit:junit:4.12'
}

猜你喜欢

转载自blog.csdn.net/qq_23195583/article/details/53783013
今日推荐