My problem is that after I added flavors to my project the flavor with a package name different from the actual source seems to have problems with accessing the files in
UPDATED ANSWER
Have you set up your flavor folders properly?
If you have two flavors (flavorOne, flavorTwo) you need to set up the source folders accordingly.
Your build.gradle file should look something like this:
productFlavors {
flavorOne {
applicationId "com.package.name"
versionCode 1
versionName "1.0"
}
flavorTwo {
applicationId "com.package.name.two"
versionCode 1
versionName "1.0"
}
}
So, here is what the folder structure would look like for those two flavors:
src
---|main
--------|java
-------------|com.package.name
--------|res
-------------|drawable
---|flavorOne
--------|java
-------------|com.package.name
--------|res
-------------|drawable
---|flavorTwo
--------|java
-------------|com.package.name
--------|res
-------------|drawable
Put the drawables for each flavor in it's associated folder.
So you would have the image.png
file for flavorOne
in that drawable folder and the image.png
for flavorTwo
in the flavorTwo
drawable folder.
This way localization will work for each flavor.
You should NOT be creating 'R' classes. These are autogenerated.
OLD ANSWER
Not really a solution to your exact problem but another approach.
You could move your image files to the assets folder instead and use this