1

I am new to android programming. I just released my app. All works well and everything. However I was thinking of making a new flavor (free) version of the app by using the flavor feature of gradle.

Now all the tutorials and example of flavors that i see tell about storing exclusive classes of different flavors separate, for instance

com.example.myapp.free

com.example.myapp.paid

and keep the common files in main. Now my issue is, since i have already released the app, I cannot change the package name of my app to the .paid name as mentioned above. However my free version will implement the same class with different logic. If I do this, I get the duplicate class:com... error

How do i get around this situation?

N J
  • 27,217
  • 13
  • 76
  • 96
poortechworker
  • 627
  • 1
  • 6
  • 21
  • see this link http://stackoverflow.com/questions/26636282/how-to-have-two-build-flavors-inherit-from-a-root-flavor-in-android-studio – N J Jun 29 '15 at 18:03
  • Thank you for the link, however it doesn't solve my problem. They already have separate flavors established. My paid app is already released and I am asking how I would avoid duplicate without changing package names. – poortechworker Jun 29 '15 at 21:57

1 Answers1

0

Finally got the solution:

defined gradle config like this:

    productFlavors {
    free {
        applicationId "com.blah.blah.free"
    }
    paid {
        applicationId "com.blah.blah"
    }

This allowed me to keep the release package same, and at the same time, I added learned the hard way to design and modularize app properly. I had make copies of my activity classes in both flavors and delete from main. Resource overriding automatically handles everything except the classes.

poortechworker
  • 627
  • 1
  • 6
  • 21