Gradle swap jniLibs resources based on build flavor

后端 未结 3 875
挽巷
挽巷 2021-01-13 10:15

I am trying to swap some resources in the res/raw folder and the jniLibs/armeabi folder based on whether its a release buildType or a

3条回答
  •  别那么骄傲
    2021-01-13 11:00

    To use flavors to vary source sets,

    productFlavors{
        phone{
        }
        tablet{
        }
    }
    

    Now structure your code like,

    src
      main
      phone
      tablet
    

    The code in main is common between both flavors, but the code in phone or tablet is only included when the respective flavor is built. That's it, you don't need to do anything else.

    The structure under phone and tablet is the same as under main (res, java, etc). You can also have a custom AndroidManifest.xml under the flavor directory. Gradle attempts to merge the flavor's AndroidManifest.xml with the one in main. In some cases you have to provide rules for how to merge.

提交回复
热议问题