How to manage two different applicationId in productFlavors?












0














I need to manage two different client code in single project so i have used productFlavors and defined flavor for each client.



Now the question is source code base is same for both but need to define different applicationId like




  1. com.abc

  2. com.def.


How would I make flavor so that code remain same for both and appId different?










share|improve this question
























  • Which code are you talking about? How does your code depend on application id?
    – Khemraj
    Nov 19 '18 at 12:12










  • You can just add suffix to applicationId like this applicationIdSuffix ".test" .
    – Khemraj
    Nov 19 '18 at 12:12










  • You can as well do this manually by right clicking on app module and create new java folder, then, in the folder, create a new package
    – Show Young Soyinka
    Nov 19 '18 at 12:15










  • @Khemraj Simple question let say two customer. 1.Apple (com.au.apple) 2. Google (com.uk.google) Project code will remain same just logo will change for both. In this case how would I define above applicationId so that both can use common code.
    – Rohan Patel
    Nov 19 '18 at 12:18
















0














I need to manage two different client code in single project so i have used productFlavors and defined flavor for each client.



Now the question is source code base is same for both but need to define different applicationId like




  1. com.abc

  2. com.def.


How would I make flavor so that code remain same for both and appId different?










share|improve this question
























  • Which code are you talking about? How does your code depend on application id?
    – Khemraj
    Nov 19 '18 at 12:12










  • You can just add suffix to applicationId like this applicationIdSuffix ".test" .
    – Khemraj
    Nov 19 '18 at 12:12










  • You can as well do this manually by right clicking on app module and create new java folder, then, in the folder, create a new package
    – Show Young Soyinka
    Nov 19 '18 at 12:15










  • @Khemraj Simple question let say two customer. 1.Apple (com.au.apple) 2. Google (com.uk.google) Project code will remain same just logo will change for both. In this case how would I define above applicationId so that both can use common code.
    – Rohan Patel
    Nov 19 '18 at 12:18














0












0








0







I need to manage two different client code in single project so i have used productFlavors and defined flavor for each client.



Now the question is source code base is same for both but need to define different applicationId like




  1. com.abc

  2. com.def.


How would I make flavor so that code remain same for both and appId different?










share|improve this question















I need to manage two different client code in single project so i have used productFlavors and defined flavor for each client.



Now the question is source code base is same for both but need to define different applicationId like




  1. com.abc

  2. com.def.


How would I make flavor so that code remain same for both and appId different?







android android-productflavors android-build-flavors






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 14:50









Ali

1,73721030




1,73721030










asked Nov 19 '18 at 12:10









Rohan Patel

5911519




5911519












  • Which code are you talking about? How does your code depend on application id?
    – Khemraj
    Nov 19 '18 at 12:12










  • You can just add suffix to applicationId like this applicationIdSuffix ".test" .
    – Khemraj
    Nov 19 '18 at 12:12










  • You can as well do this manually by right clicking on app module and create new java folder, then, in the folder, create a new package
    – Show Young Soyinka
    Nov 19 '18 at 12:15










  • @Khemraj Simple question let say two customer. 1.Apple (com.au.apple) 2. Google (com.uk.google) Project code will remain same just logo will change for both. In this case how would I define above applicationId so that both can use common code.
    – Rohan Patel
    Nov 19 '18 at 12:18


















  • Which code are you talking about? How does your code depend on application id?
    – Khemraj
    Nov 19 '18 at 12:12










  • You can just add suffix to applicationId like this applicationIdSuffix ".test" .
    – Khemraj
    Nov 19 '18 at 12:12










  • You can as well do this manually by right clicking on app module and create new java folder, then, in the folder, create a new package
    – Show Young Soyinka
    Nov 19 '18 at 12:15










  • @Khemraj Simple question let say two customer. 1.Apple (com.au.apple) 2. Google (com.uk.google) Project code will remain same just logo will change for both. In this case how would I define above applicationId so that both can use common code.
    – Rohan Patel
    Nov 19 '18 at 12:18
















Which code are you talking about? How does your code depend on application id?
– Khemraj
Nov 19 '18 at 12:12




Which code are you talking about? How does your code depend on application id?
– Khemraj
Nov 19 '18 at 12:12












You can just add suffix to applicationId like this applicationIdSuffix ".test" .
– Khemraj
Nov 19 '18 at 12:12




You can just add suffix to applicationId like this applicationIdSuffix ".test" .
– Khemraj
Nov 19 '18 at 12:12












You can as well do this manually by right clicking on app module and create new java folder, then, in the folder, create a new package
– Show Young Soyinka
Nov 19 '18 at 12:15




You can as well do this manually by right clicking on app module and create new java folder, then, in the folder, create a new package
– Show Young Soyinka
Nov 19 '18 at 12:15












@Khemraj Simple question let say two customer. 1.Apple (com.au.apple) 2. Google (com.uk.google) Project code will remain same just logo will change for both. In this case how would I define above applicationId so that both can use common code.
– Rohan Patel
Nov 19 '18 at 12:18




@Khemraj Simple question let say two customer. 1.Apple (com.au.apple) 2. Google (com.uk.google) Project code will remain same just logo will change for both. In this case how would I define above applicationId so that both can use common code.
– Rohan Patel
Nov 19 '18 at 12:18












2 Answers
2






active

oldest

votes


















2














add the code block set applicationId like below :



productFlavors {
abc {
resValue "string", "build_type", "Version " + defaultConfig.versionName
applicationId "com.abc"
}
def {
resValue "string", "build_type", "Version " + defaultConfig.versionName
applicationId "com.def"
}





share|improve this answer





















  • What will be the package name? I want both flavor use common code. I dont want to make separate packages for both.
    – Rohan Patel
    Nov 19 '18 at 12:19












  • just define applicationId "packageName" it will remains your code same for both flavour just select flavour while making APK to set package name
    – Rutvik Bhatt
    Nov 19 '18 at 12:27



















0














android will create main/ source set and directories for everything you want to share between all your build variants, so no need for creating new source set in your case.



And you could use applicationIdSuffix for different build variants, which is appended to the "base" application id when calculating the final application id for a variant.For example :
flavorDimensions "appMode"



productFlavors {

free {
dimension "appMode"
applicationIdSuffix ".free" //the application id of 'free' is com.example.com.free
}
paid {
dimension "appMode"
applicationIdSuffix ".paid"//the application id of 'free' is com.example.com.paid
}
}


The applicationIdSuffix will be appended to the package name(base application id),
com.example.com is the package name in above example.






share|improve this answer





















    Your Answer






    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: "1"
    };
    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374360%2fhow-to-manage-two-different-applicationid-in-productflavors%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    add the code block set applicationId like below :



    productFlavors {
    abc {
    resValue "string", "build_type", "Version " + defaultConfig.versionName
    applicationId "com.abc"
    }
    def {
    resValue "string", "build_type", "Version " + defaultConfig.versionName
    applicationId "com.def"
    }





    share|improve this answer





















    • What will be the package name? I want both flavor use common code. I dont want to make separate packages for both.
      – Rohan Patel
      Nov 19 '18 at 12:19












    • just define applicationId "packageName" it will remains your code same for both flavour just select flavour while making APK to set package name
      – Rutvik Bhatt
      Nov 19 '18 at 12:27
















    2














    add the code block set applicationId like below :



    productFlavors {
    abc {
    resValue "string", "build_type", "Version " + defaultConfig.versionName
    applicationId "com.abc"
    }
    def {
    resValue "string", "build_type", "Version " + defaultConfig.versionName
    applicationId "com.def"
    }





    share|improve this answer





















    • What will be the package name? I want both flavor use common code. I dont want to make separate packages for both.
      – Rohan Patel
      Nov 19 '18 at 12:19












    • just define applicationId "packageName" it will remains your code same for both flavour just select flavour while making APK to set package name
      – Rutvik Bhatt
      Nov 19 '18 at 12:27














    2












    2








    2






    add the code block set applicationId like below :



    productFlavors {
    abc {
    resValue "string", "build_type", "Version " + defaultConfig.versionName
    applicationId "com.abc"
    }
    def {
    resValue "string", "build_type", "Version " + defaultConfig.versionName
    applicationId "com.def"
    }





    share|improve this answer












    add the code block set applicationId like below :



    productFlavors {
    abc {
    resValue "string", "build_type", "Version " + defaultConfig.versionName
    applicationId "com.abc"
    }
    def {
    resValue "string", "build_type", "Version " + defaultConfig.versionName
    applicationId "com.def"
    }






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 19 '18 at 12:13









    Rutvik Bhatt

    1,052414




    1,052414












    • What will be the package name? I want both flavor use common code. I dont want to make separate packages for both.
      – Rohan Patel
      Nov 19 '18 at 12:19












    • just define applicationId "packageName" it will remains your code same for both flavour just select flavour while making APK to set package name
      – Rutvik Bhatt
      Nov 19 '18 at 12:27


















    • What will be the package name? I want both flavor use common code. I dont want to make separate packages for both.
      – Rohan Patel
      Nov 19 '18 at 12:19












    • just define applicationId "packageName" it will remains your code same for both flavour just select flavour while making APK to set package name
      – Rutvik Bhatt
      Nov 19 '18 at 12:27
















    What will be the package name? I want both flavor use common code. I dont want to make separate packages for both.
    – Rohan Patel
    Nov 19 '18 at 12:19






    What will be the package name? I want both flavor use common code. I dont want to make separate packages for both.
    – Rohan Patel
    Nov 19 '18 at 12:19














    just define applicationId "packageName" it will remains your code same for both flavour just select flavour while making APK to set package name
    – Rutvik Bhatt
    Nov 19 '18 at 12:27




    just define applicationId "packageName" it will remains your code same for both flavour just select flavour while making APK to set package name
    – Rutvik Bhatt
    Nov 19 '18 at 12:27













    0














    android will create main/ source set and directories for everything you want to share between all your build variants, so no need for creating new source set in your case.



    And you could use applicationIdSuffix for different build variants, which is appended to the "base" application id when calculating the final application id for a variant.For example :
    flavorDimensions "appMode"



    productFlavors {

    free {
    dimension "appMode"
    applicationIdSuffix ".free" //the application id of 'free' is com.example.com.free
    }
    paid {
    dimension "appMode"
    applicationIdSuffix ".paid"//the application id of 'free' is com.example.com.paid
    }
    }


    The applicationIdSuffix will be appended to the package name(base application id),
    com.example.com is the package name in above example.






    share|improve this answer


























      0














      android will create main/ source set and directories for everything you want to share between all your build variants, so no need for creating new source set in your case.



      And you could use applicationIdSuffix for different build variants, which is appended to the "base" application id when calculating the final application id for a variant.For example :
      flavorDimensions "appMode"



      productFlavors {

      free {
      dimension "appMode"
      applicationIdSuffix ".free" //the application id of 'free' is com.example.com.free
      }
      paid {
      dimension "appMode"
      applicationIdSuffix ".paid"//the application id of 'free' is com.example.com.paid
      }
      }


      The applicationIdSuffix will be appended to the package name(base application id),
      com.example.com is the package name in above example.






      share|improve this answer
























        0












        0








        0






        android will create main/ source set and directories for everything you want to share between all your build variants, so no need for creating new source set in your case.



        And you could use applicationIdSuffix for different build variants, which is appended to the "base" application id when calculating the final application id for a variant.For example :
        flavorDimensions "appMode"



        productFlavors {

        free {
        dimension "appMode"
        applicationIdSuffix ".free" //the application id of 'free' is com.example.com.free
        }
        paid {
        dimension "appMode"
        applicationIdSuffix ".paid"//the application id of 'free' is com.example.com.paid
        }
        }


        The applicationIdSuffix will be appended to the package name(base application id),
        com.example.com is the package name in above example.






        share|improve this answer












        android will create main/ source set and directories for everything you want to share between all your build variants, so no need for creating new source set in your case.



        And you could use applicationIdSuffix for different build variants, which is appended to the "base" application id when calculating the final application id for a variant.For example :
        flavorDimensions "appMode"



        productFlavors {

        free {
        dimension "appMode"
        applicationIdSuffix ".free" //the application id of 'free' is com.example.com.free
        }
        paid {
        dimension "appMode"
        applicationIdSuffix ".paid"//the application id of 'free' is com.example.com.paid
        }
        }


        The applicationIdSuffix will be appended to the package name(base application id),
        com.example.com is the package name in above example.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 19 '18 at 12:20









        navylover

        3,38521118




        3,38521118






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53374360%2fhow-to-manage-two-different-applicationid-in-productflavors%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            SQL update select statement

            'app-layout' is not a known element: how to share Component with different Modules