{"id":15374,"date":"2014-09-02T10:54:44","date_gmt":"2014-09-02T05:24:44","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=15374"},"modified":"2014-09-02T11:22:22","modified_gmt":"2014-09-02T05:52:22","slug":"building-android-application-with-different-productflavors","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/","title":{"rendered":"Building Android Application with different productFlavors"},"content":{"rendered":"<p>Applications are developed using some arbitrary values for development and QA. But, when it comes to production or releasing a new update for app, we need to change those arbitrary values to actual values.<\/p>\n<p>For instance, take an application using web services, which requires some input from user and store it in database. During development and testing, many valid but arbitrary values are provided. And, we don&#8217;t want those values inside production database. So, an option is to keep different URL for different purposes.<\/p>\n<p>But, there is another problem. We need to update our application (web service url) each time we create a build for development, QA and production.<\/p>\n<p>For this type of problem <kbd>productFlavors<\/kbd> comes to our rescue.<\/p>\n<p>In Android Studio project, open <kbd>build.gradle<\/kbd> of the module.<\/p>\n<p>[code]&lt;project-name&gt;\/&lt;module-name&gt;\/build.gradle[\/code]<\/p>\n<p>In it, inside <kbd>android<\/kbd> block, add <kbd>productFlavors<\/kbd>.<\/p>\n<p>[code]android {<br \/>\n&#8230;<\/p>\n<p>    productFlavors {<\/p>\n<p>        Development {<\/p>\n<p>        }<\/p>\n<p>        QA {<\/p>\n<p>        }<\/p>\n<p>        Production {<\/p>\n<p>        }<\/p>\n<p>    }<\/p>\n<p>}[\/code]<\/p>\n<p>Now, create three directories inside<br \/>\n[code]&lt;project-name&gt;\/&lt;module-name&gt;\/src\/Development<br \/>\n&lt;project-name&gt;\/&lt;module-name&gt;\/src\/QA<br \/>\n&lt;project-name&gt;\/&lt;module-name&gt;\/src\/Production[\/code]<\/p>\n<p>Based on the requirements, create <kbd>java<\/kbd> and <kbd>res<\/kbd> directories inside all three. If you don&#8217;t need any resource specific to the flavors then skip creating <kbd>res<\/kbd>.<\/p>\n<p>Now, create package inside each <kbd>java<\/kbd> and keep the java code there which are specific to that flavor.<\/p>\n<p>I have uploaded a demo application project on GitHub <a href=\"https:\/\/github.com\/navkrishna\/FlavourUsage\/\" target=\"_blank\">FlavourUsage<\/a>. Clone, fork, modify and create your own flavor specific application.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Applications are developed using some arbitrary values for development and QA. But, when it comes to production or releasing a new update for app, we need to change those arbitrary values to actual values. For instance, take an application using web services, which requires some input from user and store it in database. During development [&hellip;]<\/p>\n","protected":false},"author":133,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":6,"footnotes":""},"categories":[518],"tags":[4845,1503,1502],"class_list":["post-15374","post","type-post","status-publish","format-standard","hentry","category-android","tag-android","tag-android-studio","tag-productflavors"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Applications are developed using some arbitrary values for development and QA. But, when it comes to production or releasing a new update for app, we need to change those arbitrary values to actual values. For instance, take an application using web services, which requires some input from user and store it in database. During development\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Navkrishna\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Building Android Application with different productFlavors | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"Applications are developed using some arbitrary values for development and QA. But, when it comes to production or releasing a new update for app, we need to change those arbitrary values to actual values. For instance, take an application using web services, which requires some input from user and store it in database. During development\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Building Android Application with different productFlavors | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Applications are developed using some arbitrary values for development and QA. But, when it comes to production or releasing a new update for app, we need to change those arbitrary values to actual values. For instance, take an application using web services, which requires some input from user and store it in database. During development\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/building-android-application-with-different-productflavors\\\/#article\",\"name\":\"Building Android Application with different productFlavors | TO THE NEW Blog\",\"headline\":\"Building Android Application with different productFlavors\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/navkrishna\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2014-09-02T10:54:44+05:30\",\"dateModified\":\"2014-09-02T11:22:22+05:30\",\"inLanguage\":\"en-US\",\"commentCount\":3,\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/building-android-application-with-different-productflavors\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/building-android-application-with-different-productflavors\\\/#webpage\"},\"articleSection\":\"Android, Android, android studio, productFlavors\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/building-android-application-with-different-productflavors\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/android\\\/#listItem\",\"name\":\"Android\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/android\\\/#listItem\",\"position\":2,\"name\":\"Android\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/android\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/building-android-application-with-different-productflavors\\\/#listItem\",\"name\":\"Building Android Application with different productFlavors\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/building-android-application-with-different-productflavors\\\/#listItem\",\"position\":3,\"name\":\"Building Android Application with different productFlavors\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/android\\\/#listItem\",\"name\":\"Android\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/navkrishna\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/navkrishna\\\/\",\"name\":\"Navkrishna\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/building-android-application-with-different-productflavors\\\/#authorImage\",\"url\":\"https:\\\/\\\/newersworld-sf-static.tothenew.net\\\/prod\\\/profilePicFolder\\\/89a283a2-07e8-4ac0-96a5-96873f040287_navkrishna@tothenew.com.jpg\",\"width\":96,\"height\":96,\"caption\":\"Navkrishna\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/building-android-application-with-different-productflavors\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/building-android-application-with-different-productflavors\\\/\",\"name\":\"Building Android Application with different productFlavors | TO THE NEW Blog\",\"description\":\"Applications are developed using some arbitrary values for development and QA. But, when it comes to production or releasing a new update for app, we need to change those arbitrary values to actual values. For instance, take an application using web services, which requires some input from user and store it in database. During development\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/building-android-application-with-different-productflavors\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/navkrishna\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/navkrishna\\\/#author\"},\"datePublished\":\"2014-09-02T10:54:44+05:30\",\"dateModified\":\"2014-09-02T11:22:22+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Building Android Application with different productFlavors | TO THE NEW Blog","description":"Applications are developed using some arbitrary values for development and QA. But, when it comes to production or releasing a new update for app, we need to change those arbitrary values to actual values. For instance, take an application using web services, which requires some input from user and store it in database. During development","canonical_url":"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/#article","name":"Building Android Application with different productFlavors | TO THE NEW Blog","headline":"Building Android Application with different productFlavors","author":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/navkrishna\/#author"},"publisher":{"@id":"https:\/\/www.tothenew.com\/blog\/#organization"},"datePublished":"2014-09-02T10:54:44+05:30","dateModified":"2014-09-02T11:22:22+05:30","inLanguage":"en-US","commentCount":3,"mainEntityOfPage":{"@id":"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/#webpage"},"isPartOf":{"@id":"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/#webpage"},"articleSection":"Android, Android, android studio, productFlavors"},{"@type":"BreadcrumbList","@id":"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.tothenew.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/android\/#listItem","name":"Android"}},{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/android\/#listItem","position":2,"name":"Android","item":"https:\/\/www.tothenew.com\/blog\/category\/android\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/#listItem","name":"Building Android Application with different productFlavors"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/#listItem","position":3,"name":"Building Android Application with different productFlavors","previousItem":{"@type":"ListItem","@id":"https:\/\/www.tothenew.com\/blog\/category\/android\/#listItem","name":"Android"}}]},{"@type":"Organization","@id":"https:\/\/www.tothenew.com\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/www.tothenew.com\/blog\/"},{"@type":"Person","@id":"https:\/\/www.tothenew.com\/blog\/author\/navkrishna\/#author","url":"https:\/\/www.tothenew.com\/blog\/author\/navkrishna\/","name":"Navkrishna","image":{"@type":"ImageObject","@id":"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/#authorImage","url":"https:\/\/newersworld-sf-static.tothenew.net\/prod\/profilePicFolder\/89a283a2-07e8-4ac0-96a5-96873f040287_navkrishna@tothenew.com.jpg","width":96,"height":96,"caption":"Navkrishna"}},{"@type":"WebPage","@id":"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/#webpage","url":"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/","name":"Building Android Application with different productFlavors | TO THE NEW Blog","description":"Applications are developed using some arbitrary values for development and QA. But, when it comes to production or releasing a new update for app, we need to change those arbitrary values to actual values. For instance, take an application using web services, which requires some input from user and store it in database. During development","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.tothenew.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/#breadcrumblist"},"author":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/navkrishna\/#author"},"creator":{"@id":"https:\/\/www.tothenew.com\/blog\/author\/navkrishna\/#author"},"datePublished":"2014-09-02T10:54:44+05:30","dateModified":"2014-09-02T11:22:22+05:30"},{"@type":"WebSite","@id":"https:\/\/www.tothenew.com\/blog\/#website","url":"https:\/\/www.tothenew.com\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.tothenew.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Building Android Application with different productFlavors | TO THE NEW Blog","og:description":"Applications are developed using some arbitrary values for development and QA. But, when it comes to production or releasing a new update for app, we need to change those arbitrary values to actual values. For instance, take an application using web services, which requires some input from user and store it in database. During development","og:url":"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/","og:image":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Building Android Application with different productFlavors | TO THE NEW Blog","twitter:description":"Applications are developed using some arbitrary values for development and QA. But, when it comes to production or releasing a new update for app, we need to change those arbitrary values to actual values. For instance, take an application using web services, which requires some input from user and store it in database. During development","twitter:image":"https:\/\/www.tothenew.com\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"15374","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-30 02:38:14","updated":"2024-02-29 09:35:22","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tothenew.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.tothenew.com\/blog\/category\/android\/\" title=\"Android\">Android<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tBuilding Android Application with different productFlavors\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.tothenew.com\/blog"},{"label":"Android","link":"https:\/\/www.tothenew.com\/blog\/category\/android\/"},{"label":"Building Android Application with different productFlavors","link":"https:\/\/www.tothenew.com\/blog\/building-android-application-with-different-productflavors\/"}],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/15374","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/133"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=15374"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/15374\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=15374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=15374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=15374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}