Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Select target dependency configuration (Android studio scope) #20

Open
igorwojda opened this issue Mar 16, 2017 · 4 comments
Open

Select target dependency configuration (Android studio scope) #20

igorwojda opened this issue Mar 16, 2017 · 4 comments

Comments

@igorwojda
Copy link

Now all assets go to default scope (main dependency configuration), but sometimes we want to add new resource to other configuration e.g change logo/icons when rebranding app.

It would be nice to have combibox containing list of all avialable configurations to select target of generated resource

@misakuo
Copy link
Owner

misakuo commented Mar 16, 2017

Uhhh...could you provide some examples to explain it? I do not quite understand what you mean

@igorwojda
Copy link
Author

igorwojda commented Mar 16, 2017

Sure, so basically there are different product favours inside android application (product flavour is used to create different branding e.g. different logo or free/paid versions - basically the same app but with few differences in behaviour or appearance)

By default you put all the resources into (this is what this plugin does)
\app\src\main\res\drawable\logo.xml

You can place the resources also in different product flavours folders, build variant folders or built type folders.
This basically means that when you building app the resource from \app\src\main\res\drawable is used, but when you are building free product flavour resource from this flavour will override resource from main resulting in having free logo in the app.

Product flavour are combined with build types:

build variant = product flavour + built type
e.g. freeDebug = free + Debug

Example:
Assume we have 2 product flavours: free & paid
Assume we have 2 build types: Release & Debug

We can have multiple locations for our logo based on:

  1. Build type
\app\src\main\res\drawable\logo.xml (this is default name for mainRelease)
\app\src\debug\res\drawable\logo.xml
\app\src\release\res\drawable\logo.xml
  1. Product flavour
\app\src\free\res\drawable\logo.xml
\app\src\paid\res\drawable\logo.xml
  1. Build variant = product flavour + built type
\app\src\freeDebug\res\drawable\logo.xml
\app\src\freeRelease\res\drawable\logo.xml
\app\src\paidDebug\res\drawable\logo.xml
\app\src\paidRelease\res\drawable\logo.xml

I believe the best thing to address this problem would be to add ComboBox Build type containing list of all buildtypes avialable in the project (attach). Also we woudl change 'XML to' to 'Module name'

https://drive.google.com/file/d/0B4hXruznbpCVOXZhd1BibThMbEk/view

Here is a example updating icon
http://blog.brainattica.com/how-to-work-with-flavours-on-android/

Android build variants
https://developer.android.com/studio/build/build-variants.html

Feel free to ask if you need more explanation.

@misakuo
Copy link
Owner

misakuo commented Mar 17, 2017

Yes, I understand, it is build variants.
So, I only need to list of all subdirectories for src directory on each module? if I have a project like
img

I need to list the androidTest, debug, main, test to allow user to choose, is it?

@igorwojda
Copy link
Author

igorwojda commented Mar 17, 2017

Generally yes although I am not sure if there is a point of adding resources to 'test' folders, so I am 90% sure they should not be on the list.

Also keep in mind that there may be case where folder for particular build type does not exist although build type actually exists, so if you want to handle this you should get full of product flavours from build.gradle and generate proper build types (folder names) + add default ones (main, debug, release) (mabye we should have 'show only existing folders' checkbox)

productFlavors {
        free {
        }
        main {
        }
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants