4

I'd like to create another res folder in a flavor folder in android studio but i dont see an option for it. you know normally the structure looks like this:

src
 \
 main 
  |
   res

but i have another flavor which i added and now my strucuture looks like this:

src
  \
  main 
   |
   res
  \
  staging
   | 
  (i want res to appear here) 

is it possible for res to appear under staging. that way anytime i using stagingDebug variant it will first look for drawables etc inside the staging res folder ? i tried to right click and go to new but i dont see an option to create a res folder.

j2emanue
  • 60,549
  • 65
  • 286
  • 456

2 Answers2

5

I would consider two things to do what you want to achieve.

First you have to consider the directory structure. If you have two flavors, for example debug and release, and you want a different image for each flavor you will need to put your files inside following directories:

app/src/debug/res/drawable  
app/src/release/res/drawable

First one for debug flavor, second one for release flavor. I made a sample project available at GitHub that shows how to use a different image for two flavors.

The other thing that I would consider is to use a different view to browse your project items. If you check on the left of the screen, you have a drop down which allows to change the way you browse project elements, if you click on it, you will see something like this:

Project browsing views

If you click on Project Files, you will have a view pretty much like a file browser. Then if you click on src, you might need to create a directory for each flavor and then, res and drawable directory. You do this by right clicking on top of the directory, then you choose New -> Directory.

RobertoAllende
  • 8,744
  • 4
  • 30
  • 49
  • i would prefer to just have a debug folder and then have the main folder for release. and get rid of the release folder, what do you think ? – j2emanue Sep 12 '17 at 08:02
  • If you want to do that, go for it. Just be aware of potential consecuences. Debug and release are more than 'folders'. They are [build variants](https://developer.android.com/studio/build/build-variants.html) and as such, they have certain functinalities that you might need. For example, release usually requires to [sign the apk](https://developer.android.com/studio/publish/app-signing.html) which is something you will need to distribute your app, whereas debug does not require signing the apk. – RobertoAllende Sep 12 '17 at 08:26
1

No.. If you have another staging as another variant in productflavour.. you'll have to create "staging" folder under

src/staging/res/activity_main

For eg below

enter image description here

Adolf Dsilva
  • 13,092
  • 8
  • 34
  • 45
  • 1
    how did you get the res folder to appear under customer is my question ? i see how to do it. you just right click and create new Directory. i was confused because i was going to create resource directory and wasn't seeing it in the list. issue solved. – j2emanue Sep 12 '17 at 08:00