Modification of the code in the free and fee version of the annex at the same time



  • There's an app N, he's got two versions-- pay and free, every version of his ID and his operation.

    Let's say I have to make a change in grades 5 to 7, to complement them in both.

    How's it best to do that?

    I'm writing in one version right now, then copying my hands in another.



  • Use Flavors.

    Android Studio:

    1. Open File-Project Structure-Flavors. There'll be a defaultConfig. You create two flavor'a: paid and free. You tell each of them your applicationId. The rest of the data is not necessarily available, they will come from defaultConfig'a (possibly signing config, then it may also be indicated, or may not, depending on your project).
    2. Now for each of the flavor's, you can create your classes and resources, they will be merged with the code(s). The files will lie next to the main directory src. For example:

      myproject
          app
              src
                  main
                      java
                      res
                      assets
                      ...
                  paid
                      java
                      res
                      ...
                  free
                      res
                      ...
      

      2.1. The structure of the directors itself is not being created, and it will have to be done manually. Although for resources, for example, it is possible to select a sourceSet (by default main, but it is possible to choose whatever it takes) and the structure and files (if necessary) will be created.

    3. Open up on the left downstairs in the Build Variants studio and choose the option you need to launch. For example, Module: app - constitutional Build Variant: paid Debug. You switch to freeDebug, the studio will cross everything.
    4. Profit.

    References:

    • https://developer.android.com/intl/ru/tools/building/configuring-gradle.html
    • http://www.techotopia.com/index.php/An_Android_Studio_Gradle_Build_Variants_Example

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2