Feb 14 | 8:50 AM |
Mark M. | has entered the room |
Feb 14 | 8:55 AM |
Mark M. | turned on guest access |
Feb 14 | 9:05 AM |
Leora | has entered the room |
Leora |
Hi Mark :)
|
Mark M. |
hello, Leora!
|
Mark M. |
how can I help you today?
|
Leora |
Hi, we have a project with several library modules (that we own) and I would like to propagate the buildTypes I have to the children
|
Mark M. |
I have not done much with that, sorry
|
Leora |
But everytime I try and comment out the buildTypes that are copy/pasted across all modules it throws erros
|
Leora |
oh...just saw your reply
|
Feb 14 | 9:10 AM |
Mark M. |
what sort of errors?
|
Leora |
that it doesn't find the variant X in child blah blah
|
Mark M. |
I have seen people asking about that in Stack Overflow, but I have not encountered it personally, and I do not recall what the solution was
|
Mark M. |
note that solutions have probably changed a few times in recent years, as Google keep changing how this aspect of Gradle works
|
Leora |
and in the build Variants box on the left in AS, it lists all the modules with the option to set build variants on each one, which we really don't need
|
Leora |
yeah I didn't see any solution on SO
|
Mark M. |
I am sorry that I can not really help you on this
|
Leora |
Well at least this confirms that I checked your book thoroughly before bothering you ;)
|
Leora |
Maybe you can suggest a good (human readable) reference for this?
|
Mark M. |
off the top of my head, no
|
Mark M. |
if I ran into the problem, I'd be in the same position as you, in terms of searching around for options
|
Leora |
Ok thanks Mark, have a great one :)
|
Mark M. |
you too!
|
Feb 14 | 9:15 AM |
Leora |
I wonder if I can leave the buildTypes 'titles' and but leave what's inside them empty in the libs...
|
Leora |
maybe it will take from the main all the specifics inside the brackets
|
Mark M. |
by "inside the brackets", you mean that you are configuring the build type?
|
Leora |
yes
|
Mark M. |
you could always define constants and use those, both in the app module and the library modules
|
Mark M. |
for example, applicationIdSuffix ext.titlesSuffix
|
Mark M. |
where you define ext.titlesSuffix up in the top-level build.gradle file, or some other common location
|
Leora |
true
|
Leora |
but i would like not to write the pinters in EVERY modules gradle
|
Mark M. |
perhaps there is a way using "apply from:" to handle this
|
Mark M. |
I haven't tried that inside a particular closure, such as a build type
|
Leora |
hmmm
|
Mark M. |
but apply from: "../common.gradle" basically serves as the Gradle equivalent of #include in C/C++
|
Leora |
well thanks. I'll continue tinkering and waiting for build times [snooze]
|
Mark M. |
pulling in whatever you have in common.gradle (or whatever you choose to name it)
|
Feb 14 | 9:20 AM |
Leora |
yeah it IS common hhhhh
|
Leora |
all right thank you!
|
Leora | has left the room |
Anshul V. | has entered the room |
Anshul V. |
Hey Mark, Good Morning!
|
Mark M. |
hello, Anshul!
|
Mark M. |
how can I help you today?
|
Feb 14 | 9:25 AM |
Anshul V. |
I come with some app architecture related question today. I want to know if it is possible to break an existing app into 3 different play store apps with different user flows but keep the same codebase. How can I go about achieving this?
|
Mark M. |
in terms of the three different apps part, you can use product flavors for that
|
Mark M. |
at least, if the "different user flows" are not *too* different
|
Mark M. |
IOW, it unclear me how "different user flows" and "keep the same codebase" can work together
|
Mark M. |
(sorry, that should be "it is unclear to me"...)
|
Mark M. |
if your changes are minor, product flavors can handle it
|
Mark M. |
otherwise, put the common code into a library module, and have three separate app modules for the different apps
|
Anshul V. |
Hmm, but that won't necessarily lead to 3 different play store listings, would it? Its different in terms that the app names would be different as well as logos and description, but underneath the codebase would be the same with some minor changes in user flows
|
Feb 14 | 9:30 AM |
Mark M. |
"but that won't necessarily lead to 3 different play store listings, would it?" -- well, you have to actually create the listings yourself
|
Mark M. |
but each product flavor can have its own applicationId value
|
Mark M. |
along with different resources, different manifest entries, different assets, and even replacement editions of Java/Kotlin classes
|
Anshul V. |
Ah, I did not know that. My limited knowledge told me that product flavors are, for example, free/premium, but in the end, they are the same app...
|
Mark M. |
your scenario is no different than free/premium
|
Mark M. |
free/premium would also involve multiple Play Store listings, if you set them up using product flavors
|
Mark M. |
(versus having just one app that uses in-app purchases to enable premium features)
|
Feb 14 | 9:35 AM |
Anshul V. |
Hmm, I did not know that either. So, in order to achieve that, I would have to extract the code out of the monolithic /app module and divide it into different modules? with each different play store listings in different modules -> leading to different package names, but the common code shared between them an be in, say a /core library module? Am I going in the right direction?
|
Mark M. |
well, again, it depends on what you want to change
|
Mark M. |
you wrote: "Its different in terms that the app names would be different as well as logos and description, but underneath the codebase would be the same with some minor changes in user flows"
|
Mark M. |
for that, you may be able to get away with product flavors
|
Mark M. |
assign each its own applicationId (so you have unique values for the Play Store)
|
Mark M. |
assign each its own string resource values for any text
|
Mark M. |
assign each its own drawable resource values for any logos
|
Mark M. |
how you handle "some minor changes in user flows" depends on the nature of those changes
|
Mark M. |
if it is something that could be handled by simple flags, define BuildConfig constants in your product flavors in Gradle, and your Java/Kotlin code can branch based on those constants
|
Mark M. |
if you need to do a bit more than that, you might be able to get away with having 1+ Java/Kotlin classes defined in the product flavors' source sets, instead of main, so you can have different implementations per flavor
|
Mark M. |
for substantial changes, though, I suspect having a common library module, with per-app modules using it, will be a simpler solution
|
Anshul V. |
Hmm, well, for one, the features are the same, but the order in which users get those features in the app are different, for example, some users might get the feature early on when they log in, and the same feature, other users can get at later stages.
|
Feb 14 | 9:40 AM |
Mark M. |
I can't say whether or not using product flavors or separate app modules would be the better choice for that
|
Anshul V. |
I think the question also ties into making the app more modular and testable as well (but this is more of a side effect), instead of just one /app module. I was thinking if I have to split in 3 different play store listings, might as well, make the app more modular and apply test coverage as well
|
Mark M. |
"modular" != "modules in Gradle" :-)
|
Mark M. |
IOW, I don't see how any of this will make testing easier, though I can see how it will make testing harder
|
Feb 14 | 9:45 AM |
Anshul V. |
Ah, that is GTK. :) I have not done any testing on the code as of now, and after reading up on clean architecture and knowing what we can achieve having different modules in gradle for different layers of the app, I thought, in my silly head, that this can achieve both purposes that I want. Different apps, more modular/interface laced codebase leading to easier testing
|
Mark M. |
having a modular codebase helps with testing
|
Mark M. |
but it is unlikely that splitting code into modules will help with testing
|
Mark M. |
despite our ability to invent new nouns, we tend to overuse things like "module" :-(
|
Anshul V. |
Ah, so you are saying that I can achieve the same thing within the /app module but having different "modules/packages" within the /app to achieve the desired result?
|
Mark M. |
using different Java packages can help enforce a modular codebase
|
Mark M. |
it's not a requirement
|
Anshul V. |
Note to self, read up on product flavors :)
|
Feb 14 | 9:50 AM |
Anshul V. |
Hmm, the current condition of the app, it's a dependency hell, not at all easily testable. There are so many God activities doing so much of work, I want to steer the app in the direction of a known app architecture, such as MVVM, along with incorporating the use of Jetpack and some standard libraries like Dagger2/RxJava2, but my limited knowledge halts the progress. You can say, I am not sound for taking architecture level decisions for the app, but I would definitely like to give this a try
|
Feb 14 | 9:55 AM |
Mark M. |
that sounds fine... but having multiple Gradle modules are not necessary to achieve that
|
Mark M. |
having multiple Gradle modules for your three-apps-on-the-Play-Store requirement might be appropriate (if you decided you need more than product flavors)
|
Mark M. |
IMHO, the three-apps-on-the-Play-Store work is independent of the make-the-code-more-modular-and-testable work
|
Anshul V. |
Ah, thank you for telling me that!
|
Anshul V. |
I would definitely look into this more before I come bothering you again with questions :)
|
Mark M. |
you are welcome to bother me with questions -- that's the point behind the office hours!
|
Anshul V. |
Haha, thank you for all your help, Mark! I appreciate it.
|
Feb 14 | 10:00 AM |
Anshul V. |
You have a good day!
|
Mark M. |
you too!
|
Mark M. |
note that the transcript of this chat will be posted to https://commonsware.com/office-hours/ shortly
|
Mark M. |
the next chat is Saturday at 4pm US Eastern
|
Anshul V. | has left the room |
Mark M. | turned off guest access |