I am about to start an Android application, I want to release two versions, one lite and one pro .
The two versions will have shared code and depending on whether it is the pro version, it will have extra options.
More or less I have read something about what to do with flavors but I am very new to the world of Android development.
I don't know if you have any specific questions or about part of the process, I'll leave this to you, I hope it helps (based on AS):
Well we press F4or
Android view
app
>>Open Module Settings
, to use F4you have to have selectedapp
.we create the names in this case
lite
andpro
ect with the +one that appears in the image.You can use the fields that appear when adding your flavor and fill them with the data you need,
application id
,code
,name
,Sdk
Then you can look at yourself
build gradle file
and you will have something similar to this:Now create the folders where we will put the dependent code of each of the flavors, you put these folders inside
src
enview mode Project
and (I hope I remember to put a picture of this) and they must have the same name used when creating the flavors/flavours, the The rest of the shared/common code will continue to be placed/located insidemain
for this view, and the one that is unique for each flavor you can see an example for a drawable in the image, creating the directory based on the structure that AS manages as you seeres/drawable/imagen.png
is as if you would like to create it in main for your "normal" application but now it is inside the flavor, I hope it is understood.Note that it is in the
view project
not in theAndroid
.Notes: you can see that the directory has been marked
res
in the lite flavor, because that is the one that is selected invariants
which I will leave you an image.To change the flavor on the edge of AS, the button is usually
Build Variants
there, we can establish it.To create code for each variant is similar to the example in the images, it would be created within the directory similar to the one used in
main
but as indicated in the images above:and to call it it would be something similar to this, because when one flavor or another is selected, it will be searched in the directory that is indicated:
For each flavor you can put something like this in the one
module settings
corresponding to each example flavor:Additional: http://developer.android.com/intl/es/tools/building/configuring-gradle.html
How about, you really don't have to prepare Android Studio to prepare lite or pro versions of your app. It is your application (project) that you really have to prepare, I think the question is poorly formulated. In any case, the configuration of versions or buildVariants is done through Gradle (there is even a wizard), when flavors of an app are configured, the content must be distributed (res/, src/, etc.) that makes them different in their corresponding directory. Since when you define a flavor for your app, a specific directory will be created for it.
In your /app/build.gradle file you should have something similar to this
where you can see the 2 versions of the app (demoConfig and productionConfig)
At the directory level you will see something like this
for the demoConfig version, the code, resources, xml and others must be placed in the folder generated for the buildVariant and in the main folder is the productive code (and resources) (without limitations).
When you go to distribute the applications, when generating the apk is where you must indicate what type of APK you want to generate, the lite or the pro.
Here they explain it very well http://developer.android.com/ and here something in Spanish
I hope it guides you, greetings,
Certainly the configuration for Product Flavors can help you, the documentation in English can be found here Configuring Gradle Builds , but I am writing to you how you would
build.gradle
configure these 2 flavors, assuming that the 2 have the same dependencies:Remember to create the directories where the versions to be generated will be contained:
Actually it is very simple, unfortunately I did not find tutorials in Spanish but in this tutorial you can see in point 5.3 through the images what I tell you: 5.3. Defining product flavors in your Gradle build file
Regarding what they explain, I would like to ask a question.
when creating the lite and the pro (APK) suppose I have the lite installed
when installing the pro it overwrites the lite or a new app with the .pro extension is installed
I have that doubt because I have tried and two apps are installed, I would like to know how to get the lite to overwrite
Thank you