Basically, I have a class, ClassThatUsesFoo
, which uses class Foo
. However, I have two different versions of Foo
, each in a separate build variant. In variantB
, Foo
needs to access a resource, whereas variantA
does not.
The issue is that, when I activate variantB
, Android Studio thinks it can't resolve R.someRawResource
inside variantB
's version of Foo
, even though when I actually compile and run the app, everything works as expected. (The resource is resolved just fine).
Here's what the structure looks like:
MyProject
|- MyModule
|- src
|- main
| |- java
| | |- ClassThatUsesFoo.java
| |
| |- res (Empty)
|
|- variantA
| |- java
| | |- Foo.java (Version of Foo that does NOT use resources)
| |
| |- res (Empty)
|
|- variantB
| |- java
| | |- Foo.java (Version of Foo that DOES use resources)
| |
| |- res
| | |- raw
| | | |- someRawResource.file
And here's the relaveant snippet from the Gradle file:
flavorDimensions 'type'
productFlavors {
variantA {
dimension 'type'
}
variantB {
dimension 'type'
}
}
Just to be clear here, both build variants compile and run as expected. The issue is Android Studio is confused.
Things I have tried:
- Resync with Gradle files
- Rebuild project
- Clean project
Any idea what could be wrong here? It seems like there might be a bug in Android Studio, since everything compiles and runs as expected...
System information:
- Ubuntu 16.04
- Android Studio v3.4.2