It is not possible to reconfigure gradle under new requirements.

I updated the gradle plugin and broke the build system for different assemblies.

There were: 1) three folders were made in src

  • src/main with shared files
  • src/stagingEnvironment with src/stagingEnvironment files, including a manifest
  • src/productionEnvironment with files for sale, including the manifest

2) in app/gradle

2.1) setting up resources:

 sourceSets { main { java.srcDirs = ['src/main/java'] res.srcDirs = ['src/main/res'] assets.srcDirs = ['src/main/assets'] } stagingEnvironment { java.srcDirs = ['src/stagingEnvironment/java'] res.srcDirs = ['src/stagingEnvironment/res'] manifest.srcFile manifestStagingPath jniLibs.srcDir jniLibsPath } productionEnvironment { java.srcDirs = ['src/productionEnvironment/java'] res.srcDirs = ['src/productionEnvironment/res'] manifest.srcFile manifestProductionPath jniLibs.srcDir jniLibsPath } } 

2.2) customize flavors:

 productFlavors { stagingEnvironment { applicationId 'com.example' versionCode Integer.valueOf(StagingVersionCode) versionName StagingVersionName } productionEnvironment { applicationId 'com.example' versionCode Integer.valueOf(ProductionVersionCode) versionName ProductionVersionName } } 

2.3) customize build types

 buildTypes { debug { minifyEnabled false } release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), defProguardFiles } } 

Accordingly, I saw in the selection options panel

  • stagingEnvironmentDebug
  • stagingEnvironmentRelease
  • productionEnvironmentDebug
  • productionEnvironmentRelease

===================================

After updating the plug-in, the error Error:All flavors must now belong to a named flavor dimension. appeared Error:All flavors must now belong to a named flavor dimension. By analogy with the documentation, I added flavorDimensions "dev", "prod" and in the blocks of flores these names:

 productFlavors { stagingEnvironment { applicationId 'com.example' versionCode Integer.valueOf(StagingVersionCode) versionName StagingVersionName dimension 'dev' } productionEnvironment { applicationId 'com.example' versionCode Integer.valueOf(ProductionVersionCode) versionName ProductionVersionName dimension 'prod' } } 

Problem 1: now in the selection panel of the selection cases there are only two options for the “squeezed” stagingEnvironmentProductionEnvironmentDebug stagingEnvironmentProductionEnvironmentRelease - how to prevent them from merging between?

Problem 2: (probably follows from the first) - when trying to build, it writes Manifest merger failed with multiple errors, see logs

    1 answer 1

    Made. It turned out that the flavors are not merdzhili among themselves, they need to give the same dimension.

    Here is a fully working code with the application being split into two environments.

     sourceSets { main { java.srcDirs = ['src/common/java'] res.srcDirs = ['src/common/res'] assets.srcDirs = ['src/common/assets'] manifest.srcFile manifestCommonPath } devServer { java.srcDirs = ['src/devServer/java'] res.srcDirs = ['src/devServer/res'] manifest.srcFile manifestStagingPath jniLibs.srcDir jniLibsPath } prodServer { java.srcDirs = ['src/prodServer/java'] res.srcDirs = ['src/prodServer/res'] manifest.srcFile manifestProductionPath jniLibs.srcDir jniLibsPath } } flavorDimensions "environment" productFlavors { devServer { applicationId 'com.example' versionCode Integer.valueOf(StagingVersionCode) versionName StagingVersionName dimension 'environment' } prodServer { applicationId 'com.example' versionCode Integer.valueOf(ProductionVersionCode) versionName ProductionVersionName dimension 'environment' } } 

    Shared files are in src / common. The files that are used in server devs (manifest, string and all that) are in src / devServer, and for sale - src / prodServer. If you are interested in the complete code of the gredl, here is the gist Successful development! )