Reputation: 466
I want to use same source code but different resources and menifest for two different build variant. this is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId 'com.test.project'
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
FV {
applicationId "com.test.project"
versionName "1.0"
}
AV {
applicationId "com.test.project"
versionName "1.0"
}
}
sourceSets.AV {
manifest.srcFile 'resources/av_res/AndroidManifest.xml'
res.srcDirs = ['res', 'resources/av_res/res']
}
sourceSets.FV {
manifest.srcFile 'resources/fv_res/AndroidManifest.xml'
res.srcDirs = ['res', 'resources/fv_res/res']
}
}
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile files('libs/commons-codec-1.9.jar')
compile files('libs/sdk.jar')
compile files('libs/libGoogleAnalytics.jar')
}
in this i am getting an error :
Error:A problem was found with the configuration of task ':app:checkDebugManifest'.
File 'D:\nitin\projects\FV\SFV\app\src\main\AndroidManifest.xml' specified for property 'manifest' does not exist.
Please help.
Upvotes: 0
Views: 2014
Reputation: 160
When using productFlavors you can create specific folders for them. In your case you can create the folder "FV" and "AV" beside your "main" folder.
it should look something like this:
src/
main/
AndroidManifest.xml
res/
...
FV/
AndroidManifest.xml
res/
...
AV/
AndroidManifest.xml
res/
...
This way you will be able to remove the code in your build.gradle where you specify certain directories since the build system will automatically detect them.
Upvotes: 1