I have two apps in the same codebase. They use the same java files and save res files, except for the values and drawable folders, which have the same files & filenames but different content.
The problem I'm having is that when my Gradle builds, I am having a problem because everywhere that I use R I have an error
Cannot resolve symbol R
My build.gradle file looks like this (with a few settings left out for brevity):
android {
signingConfigs {
// left out
}
compileSdkVersion 23
buildToolsVersion "23.0.1"
useLibrary 'org.apache.http.legacy'
lintOptions {
disable "ResourceType"
}
defaultConfig {
applicationId = "com.au.testapp"
minSdkVersion 16
targetSdkVersion 23
versionCode = 1
buildConfigField 'String', 'app_ver_numb', '"1.00"'
multiDexEnabled = true
}
sourceSets {
main {
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
res.srcDirs = ['res/main']
manifest.srcFile 'AndroidManifest.xml'
}
flavorone{
res.srcDirs = ['res/flavorone']
}
flavortwo{
res.srcDirs = ['res/flavortwo']
}
instrumentTest.setRoot('tests')
}
productFlavors {
flavorone {
applicationId "com.au.testapp.flavorone"
versionName = "''"
buildConfigField 'String', 'app_id', '"79"'
}
flavortwo {
applicationId "com.au.testapp.flavortwo"
versionName = "''"
buildConfigField 'String', 'app_id', '"79"'
}
}
buildTypes {
debug {
productFlavors.flavorone.signingConfig signingConfigs.flavorone
productFlavors.flavortwosigningConfig signingConfigs.flavortwo
}
release {
productFlavors.flavorone.signingConfig signingConfigs.flavorone
productFlavors.flavortwo.signingConfig signingConfigs.flavortwo
minifyEnabled true
shrinkResources true
proguardFile getDefaultProguardFile('proguard-android.txt')
}
}
}
My folder structure looks like this:
src
com
au
testapp
adapter
utils
db
common
...
res
main
anim
animator
...
drawable
layout
values
...
flavorone
drawable
values
flavortwo
drawable
values
When I build this in Gradle I don't get any errors, but when I build the project my java files have errors all through them because they can't find R.. I'm guessing it's to do with the package name not being correct due to my build flavor setup.
Any ideas?