Gradle for product flavor

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
0
down vote

favorite













I have multiple apps with same source code. So I dive into the product Flavor. All apps have same flow. Only their name ,color sheme packageName and appIcon is different.




One base url is different all other data is same. I want to have single code for all the apps. So I created different folder for holding string and color.xml for each flavor under app->src directory. I want not to add other product flavor resources while signing build.



android 
compileSdkVersion 25
buildToolsVersion '27.0.2'
flavorDimensions "tier"

defaultConfig
applicationId "com.example.broadpeak.gradlepracticing"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

signingConfigs
appleFlavor
keyAlias 'appleFlavor'
storeFile file('E:/keystoreForTest/appleFlavor.jks')
keyPassword 'password'
storePassword 'password'


mangoFlavor
keyAlias 'mangoFlavor'
storeFile file('E:/keystoreForTest/chocolateFlavor.jks')
keyPassword 'password'
storePassword 'password'


chocolateFlavor
keyAlias 'chocolateFlavor'
storeFile file('E:/keystoreForTest/chocolateFlavor.jks')
keyPassword 'password'
storePassword 'password'


sourceSets

/*main
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src/commonFiles/java']
resources.srcDirs = ['src/commonFiles/java']
aidl.srcDirs = ['src/commonFiles/java']
renderscript.srcDirs = ['src/commonFiles/java']
res.srcDirs = ['res']
assets.srcDirs = ['assets']

flavor1
java.srcDirs = ['src-flavor1']
res.srcDirs = ['res-flavor1']
*/

appleFlavorDebug
res.srcDirs =
[
'/src/appleFlavor/res/values/colors',
'/src/appleFlavor/res/values/styles',
'/src/appleFlavor/res/values/string'
]


productFlavors
appleFlavor
applicationId "broadpeak.apple.flavor"
versionCode 1
versionName "1.0"
buildConfigField "int", "COLORING", "0xff0000"
buildConfigField "String", "FOO_STRING", ""foo11""
buildConfigField "boolean", "LOG", "false"
resValue "string", "new_name", "Apple"
manifestPlaceholders = [appName: "Apple"]
flavorDimensions "tier"
signingConfig signingConfigs.appleFlavor

/*manifestPlaceholders = [
appIcon: "@mipmap/ic_launcher_test" -- android:icon="$appIcon" in application TAg in manifest*/

mangoFlavor
applicationId "broadpeak.mango.flavor"
versionCode 1
versionName "1.0"
buildConfigField "int", "COLORING", "0xffff00"
buildConfigField "String", "FOO_STRING", ""foo12""
buildConfigField "boolean", "LOG", "false"
resValue "string", "new_name", "Mango"
manifestPlaceholders = [appName: "Mango"]
flavorDimensions "tier"
signingConfig signingConfigs.mangoFlavor

chocolateFlavor
applicationId "broadpeak.chocolate.flavor"
versionCode 1
versionName "1.0"
buildConfigField "int", "COLORING", "0x00ffff"
buildConfigField "String", "FOO_STRING", ""foo13""
buildConfigField "boolean", "LOG", "true"
resValue "string", "new_name", "Chocolate"
manifestPlaceholders = [appName: "Chocolate"]
flavorDimensions "tier"
signingConfig signingConfigs.chocolateFlavor


buildTypes
release
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

/*signingConfig signingConfigs.appleFlavor
signingConfig signingConfigs.mangoFlavor
signingConfig signingConfigs.chocolateFlavor*/

debug
minifyEnabled false
shrinkResources false










share|improve this question

























    up vote
    0
    down vote

    favorite













    I have multiple apps with same source code. So I dive into the product Flavor. All apps have same flow. Only their name ,color sheme packageName and appIcon is different.




    One base url is different all other data is same. I want to have single code for all the apps. So I created different folder for holding string and color.xml for each flavor under app->src directory. I want not to add other product flavor resources while signing build.



    android 
    compileSdkVersion 25
    buildToolsVersion '27.0.2'
    flavorDimensions "tier"

    defaultConfig
    applicationId "com.example.broadpeak.gradlepracticing"
    minSdkVersion 16
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    signingConfigs
    appleFlavor
    keyAlias 'appleFlavor'
    storeFile file('E:/keystoreForTest/appleFlavor.jks')
    keyPassword 'password'
    storePassword 'password'


    mangoFlavor
    keyAlias 'mangoFlavor'
    storeFile file('E:/keystoreForTest/chocolateFlavor.jks')
    keyPassword 'password'
    storePassword 'password'


    chocolateFlavor
    keyAlias 'chocolateFlavor'
    storeFile file('E:/keystoreForTest/chocolateFlavor.jks')
    keyPassword 'password'
    storePassword 'password'


    sourceSets

    /*main
    manifest.srcFile 'AndroidManifest.xml'
    java.srcDirs = ['src/commonFiles/java']
    resources.srcDirs = ['src/commonFiles/java']
    aidl.srcDirs = ['src/commonFiles/java']
    renderscript.srcDirs = ['src/commonFiles/java']
    res.srcDirs = ['res']
    assets.srcDirs = ['assets']

    flavor1
    java.srcDirs = ['src-flavor1']
    res.srcDirs = ['res-flavor1']
    */

    appleFlavorDebug
    res.srcDirs =
    [
    '/src/appleFlavor/res/values/colors',
    '/src/appleFlavor/res/values/styles',
    '/src/appleFlavor/res/values/string'
    ]


    productFlavors
    appleFlavor
    applicationId "broadpeak.apple.flavor"
    versionCode 1
    versionName "1.0"
    buildConfigField "int", "COLORING", "0xff0000"
    buildConfigField "String", "FOO_STRING", ""foo11""
    buildConfigField "boolean", "LOG", "false"
    resValue "string", "new_name", "Apple"
    manifestPlaceholders = [appName: "Apple"]
    flavorDimensions "tier"
    signingConfig signingConfigs.appleFlavor

    /*manifestPlaceholders = [
    appIcon: "@mipmap/ic_launcher_test" -- android:icon="$appIcon" in application TAg in manifest*/

    mangoFlavor
    applicationId "broadpeak.mango.flavor"
    versionCode 1
    versionName "1.0"
    buildConfigField "int", "COLORING", "0xffff00"
    buildConfigField "String", "FOO_STRING", ""foo12""
    buildConfigField "boolean", "LOG", "false"
    resValue "string", "new_name", "Mango"
    manifestPlaceholders = [appName: "Mango"]
    flavorDimensions "tier"
    signingConfig signingConfigs.mangoFlavor

    chocolateFlavor
    applicationId "broadpeak.chocolate.flavor"
    versionCode 1
    versionName "1.0"
    buildConfigField "int", "COLORING", "0x00ffff"
    buildConfigField "String", "FOO_STRING", ""foo13""
    buildConfigField "boolean", "LOG", "true"
    resValue "string", "new_name", "Chocolate"
    manifestPlaceholders = [appName: "Chocolate"]
    flavorDimensions "tier"
    signingConfig signingConfigs.chocolateFlavor


    buildTypes
    release
    minifyEnabled true
    shrinkResources true
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

    /*signingConfig signingConfigs.appleFlavor
    signingConfig signingConfigs.mangoFlavor
    signingConfig signingConfigs.chocolateFlavor*/

    debug
    minifyEnabled false
    shrinkResources false










    share|improve this question





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite












      I have multiple apps with same source code. So I dive into the product Flavor. All apps have same flow. Only their name ,color sheme packageName and appIcon is different.




      One base url is different all other data is same. I want to have single code for all the apps. So I created different folder for holding string and color.xml for each flavor under app->src directory. I want not to add other product flavor resources while signing build.



      android 
      compileSdkVersion 25
      buildToolsVersion '27.0.2'
      flavorDimensions "tier"

      defaultConfig
      applicationId "com.example.broadpeak.gradlepracticing"
      minSdkVersion 16
      targetSdkVersion 25
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

      signingConfigs
      appleFlavor
      keyAlias 'appleFlavor'
      storeFile file('E:/keystoreForTest/appleFlavor.jks')
      keyPassword 'password'
      storePassword 'password'


      mangoFlavor
      keyAlias 'mangoFlavor'
      storeFile file('E:/keystoreForTest/chocolateFlavor.jks')
      keyPassword 'password'
      storePassword 'password'


      chocolateFlavor
      keyAlias 'chocolateFlavor'
      storeFile file('E:/keystoreForTest/chocolateFlavor.jks')
      keyPassword 'password'
      storePassword 'password'


      sourceSets

      /*main
      manifest.srcFile 'AndroidManifest.xml'
      java.srcDirs = ['src/commonFiles/java']
      resources.srcDirs = ['src/commonFiles/java']
      aidl.srcDirs = ['src/commonFiles/java']
      renderscript.srcDirs = ['src/commonFiles/java']
      res.srcDirs = ['res']
      assets.srcDirs = ['assets']

      flavor1
      java.srcDirs = ['src-flavor1']
      res.srcDirs = ['res-flavor1']
      */

      appleFlavorDebug
      res.srcDirs =
      [
      '/src/appleFlavor/res/values/colors',
      '/src/appleFlavor/res/values/styles',
      '/src/appleFlavor/res/values/string'
      ]


      productFlavors
      appleFlavor
      applicationId "broadpeak.apple.flavor"
      versionCode 1
      versionName "1.0"
      buildConfigField "int", "COLORING", "0xff0000"
      buildConfigField "String", "FOO_STRING", ""foo11""
      buildConfigField "boolean", "LOG", "false"
      resValue "string", "new_name", "Apple"
      manifestPlaceholders = [appName: "Apple"]
      flavorDimensions "tier"
      signingConfig signingConfigs.appleFlavor

      /*manifestPlaceholders = [
      appIcon: "@mipmap/ic_launcher_test" -- android:icon="$appIcon" in application TAg in manifest*/

      mangoFlavor
      applicationId "broadpeak.mango.flavor"
      versionCode 1
      versionName "1.0"
      buildConfigField "int", "COLORING", "0xffff00"
      buildConfigField "String", "FOO_STRING", ""foo12""
      buildConfigField "boolean", "LOG", "false"
      resValue "string", "new_name", "Mango"
      manifestPlaceholders = [appName: "Mango"]
      flavorDimensions "tier"
      signingConfig signingConfigs.mangoFlavor

      chocolateFlavor
      applicationId "broadpeak.chocolate.flavor"
      versionCode 1
      versionName "1.0"
      buildConfigField "int", "COLORING", "0x00ffff"
      buildConfigField "String", "FOO_STRING", ""foo13""
      buildConfigField "boolean", "LOG", "true"
      resValue "string", "new_name", "Chocolate"
      manifestPlaceholders = [appName: "Chocolate"]
      flavorDimensions "tier"
      signingConfig signingConfigs.chocolateFlavor


      buildTypes
      release
      minifyEnabled true
      shrinkResources true
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

      /*signingConfig signingConfigs.appleFlavor
      signingConfig signingConfigs.mangoFlavor
      signingConfig signingConfigs.chocolateFlavor*/

      debug
      minifyEnabled false
      shrinkResources false










      share|improve this question












      I have multiple apps with same source code. So I dive into the product Flavor. All apps have same flow. Only their name ,color sheme packageName and appIcon is different.




      One base url is different all other data is same. I want to have single code for all the apps. So I created different folder for holding string and color.xml for each flavor under app->src directory. I want not to add other product flavor resources while signing build.



      android 
      compileSdkVersion 25
      buildToolsVersion '27.0.2'
      flavorDimensions "tier"

      defaultConfig
      applicationId "com.example.broadpeak.gradlepracticing"
      minSdkVersion 16
      targetSdkVersion 25
      versionCode 1
      versionName "1.0"
      testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

      signingConfigs
      appleFlavor
      keyAlias 'appleFlavor'
      storeFile file('E:/keystoreForTest/appleFlavor.jks')
      keyPassword 'password'
      storePassword 'password'


      mangoFlavor
      keyAlias 'mangoFlavor'
      storeFile file('E:/keystoreForTest/chocolateFlavor.jks')
      keyPassword 'password'
      storePassword 'password'


      chocolateFlavor
      keyAlias 'chocolateFlavor'
      storeFile file('E:/keystoreForTest/chocolateFlavor.jks')
      keyPassword 'password'
      storePassword 'password'


      sourceSets

      /*main
      manifest.srcFile 'AndroidManifest.xml'
      java.srcDirs = ['src/commonFiles/java']
      resources.srcDirs = ['src/commonFiles/java']
      aidl.srcDirs = ['src/commonFiles/java']
      renderscript.srcDirs = ['src/commonFiles/java']
      res.srcDirs = ['res']
      assets.srcDirs = ['assets']

      flavor1
      java.srcDirs = ['src-flavor1']
      res.srcDirs = ['res-flavor1']
      */

      appleFlavorDebug
      res.srcDirs =
      [
      '/src/appleFlavor/res/values/colors',
      '/src/appleFlavor/res/values/styles',
      '/src/appleFlavor/res/values/string'
      ]


      productFlavors
      appleFlavor
      applicationId "broadpeak.apple.flavor"
      versionCode 1
      versionName "1.0"
      buildConfigField "int", "COLORING", "0xff0000"
      buildConfigField "String", "FOO_STRING", ""foo11""
      buildConfigField "boolean", "LOG", "false"
      resValue "string", "new_name", "Apple"
      manifestPlaceholders = [appName: "Apple"]
      flavorDimensions "tier"
      signingConfig signingConfigs.appleFlavor

      /*manifestPlaceholders = [
      appIcon: "@mipmap/ic_launcher_test" -- android:icon="$appIcon" in application TAg in manifest*/

      mangoFlavor
      applicationId "broadpeak.mango.flavor"
      versionCode 1
      versionName "1.0"
      buildConfigField "int", "COLORING", "0xffff00"
      buildConfigField "String", "FOO_STRING", ""foo12""
      buildConfigField "boolean", "LOG", "false"
      resValue "string", "new_name", "Mango"
      manifestPlaceholders = [appName: "Mango"]
      flavorDimensions "tier"
      signingConfig signingConfigs.mangoFlavor

      chocolateFlavor
      applicationId "broadpeak.chocolate.flavor"
      versionCode 1
      versionName "1.0"
      buildConfigField "int", "COLORING", "0x00ffff"
      buildConfigField "String", "FOO_STRING", ""foo13""
      buildConfigField "boolean", "LOG", "true"
      resValue "string", "new_name", "Chocolate"
      manifestPlaceholders = [appName: "Chocolate"]
      flavorDimensions "tier"
      signingConfig signingConfigs.chocolateFlavor


      buildTypes
      release
      minifyEnabled true
      shrinkResources true
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

      /*signingConfig signingConfigs.appleFlavor
      signingConfig signingConfigs.mangoFlavor
      signingConfig signingConfigs.chocolateFlavor*/

      debug
      minifyEnabled false
      shrinkResources false












      share|improve this question










      share|improve this question




      share|improve this question









      asked Feb 8 at 10:27









      Xar E Ahmer

      1314




      1314

























          active

          oldest

          votes











          Your Answer




          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "196"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );








           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f187083%2fgradle-for-product-flavor%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes










           

          draft saved


          draft discarded


























           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f187083%2fgradle-for-product-flavor%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Chat program with C++ and SFML

          Function to Return a JSON Like Objects Using VBA Collections and Arrays

          Will my employers contract hold up in court?