In build.gradle
, I have product settings:
productFlavors { AlternateFlavour { applicationId "com.myapp.alternateflavour" } }
Then, in the sourceSets section, I use different resources, resources, and manifest directories for these flavors:
sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } AlternateFlavour { manifest.srcFile 'manifest-tmp/AlternateFlavour/AndroidManifest.xml' java.srcDirs = ['src'] res.srcDirs = ['res-tmp/AlternateFlavour'] assets.srcDirs = ['assets-tmp/AlternateFlavour'] } }
OK so far.
In this manifesto, used by a fragrance that is partially generated automatically, I:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myapp.myapp" android:versionCode="1010001" android:versionName="V1.1.0.1" >
but in the original manifest in the root project, the following looks:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myapp.myapp" android:versionCode="1010000" android:versionName="V1.1.0.DEBUG" >
This will result in a Gradle error:
Error: Attribute manifest@versionCode value=(1010001) from AndroidManifest.xml:4:5-28 is also present at AndroidManifest.xml:4:5-28 value=(1010000). Attributes of <manifest> elements are not merged.
Why is he trying to merge with the original manifesto in general when I indicated that he should look elsewhere?
And how can I stop this?
I expect some to question why I do it this way at all, or really why I don't use the proposed flavor design framework. Well, I need a normal manifest to use outside Gradle, for example. for deployment from Eclipse (one at a time, please!), and I also need versions that will be inserted by the build process.