Use different resources (graphics and strings) for different application flavors using gradle

╄→尐↘猪︶ㄣ 提交于 2019-11-29 07:38:48

If you can rearrange your files, that's the simplest way to fix this.

You want to put them like this:

yourApp/
  src/
    main/
      java/
      res/
    flav1/
      java/
      res/
    flav2/
      java/
      res/
    flav3/
      java/
      res/

Then in build.gradle, you can get rid of sourceSets entirely. Keep productFlavors.

As far as the overriding of resources, it should be automatic: "The build system merges all the resources from the all the source directories. If different folders contain resources with the same name for a build variant, the priority order is the following: build type resources override those from the product flavor, which override the resources in the main source directory."

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!