Folder naming convention for gradle build variants

前端 未结 3 1047
孤独总比滥情好
孤独总比滥情好 2020-12-24 08:49

I have been struggling for a while with gradle and build variants.

I have these build types defined:

  • debug
  • release

And these fl

3条回答
  •  一整个雨季
    2020-12-24 09:27

    The folder structure while creating build variants should be:

    app
       |
       ->src
            |
            ->buildvariantname1(as defined in gradle)
                                |
                                ->java (follow the same structure here, as in main folder)
                                ->res (follow the same structure here, as in main folder)       
    

    Now on selecting the specific variant, like buildVariantname1debug, the changes written in the res folder under this variant will be selected.

    The app name should be defined under string.xml under res->values folder so that the app name gets fetched depending upon the value in the xml under each build variant. Same goes for app icons.

    First image shows how to declare build variants(flavors with different package names)

    The second image shows, how the project structure looks like if you want each flavor to have a different code, drawables and manifest as well. Keep in mind MainActivity is deleted from the main folder so that it can exist in each build variant

提交回复
热议问题