Android一套代码打不同的包工程配置详解

1、

defaultConfig {
    //
    flavorDimensions "default"
}

2、

android{

productFlavors {
    //开发环境
    developenv {
        buildConfigField "Integer", "ENV_TYPE", "1"
        applicationId 'xxx'
        manifestPlaceholders = [
                app_name: "开发",
        ]
    }
    //生产环境
    productenv {
        buildConfigField "Integer", "ENV_TYPE", "2"
        applicationId 'xxx'
        manifestPlaceholders = [
                app_name: "生产",
        ]
    }
}

 

}

3、与android{} 同级

configurations {
    developenvDebugImplementation
    developenvReleaseImplementation
    productenvReleaseImplementation
    productenvDebugImplementation
}

 

4、

repositories {
    flatDir {
        dirs 'libs'
    }
}

5、

developenvImplementation project(path: ':xxxlibrary')

6、

 

Android一套代码打不同的包工程配置详解

参考 :https://blog.****.net/helloworld19870427/article/details/83072699