We have multiple projects, depending on a many Android lib modules. To avoid duplicated xml tags in the apps manifests, we put the relevant receivers, services and activities in their respective modules.
Till today, we used:
Today we've updated to:
Up until this update, everything worked just fine and the manifests were merged, we had conflicts and we fixed them. As of the update we've done, the manifests will not merge, at all!!
--- Update 1 ---
We've used the Merged Manifest view, and saw that it just doesn't include the manifests in the merge, the only thing it does merge from the modules manifest is the permissions, so for example, if I add a new permission to a modules manifest it would ONLY merge it and not the rest of the elements!
I guarantee there are a lot of stuff to merge!
--- Update 2 ---
It seems that everything outside the application tag it merges into the main manifest, and everything within the application tag, it doesn't.
--- Update 3 ---
Module that doesn't merge:
Gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
jniDebuggable true
}
}
}
dependencies {
compile project(path: ':android-infra')
compile 'com.google.android.gms:play-services-gcm:9.0.0'
compile project(path: ':engine-core-server')
compile project(path: ':engine-core-aneeda')
}
Manifest:
<manifest package="com.sensiya.voip.managers.gcm"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="com.google.android.c2dm.permission.KAKI"/>
<application
tools:node="replace">
<service
android:enabled="true"
android:name="com.sensiya.voip.managers.gcm.GcmIntentService"/>
<receiver android:name="com.sensiya.voip.managers.gcm.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE"/>
<category android:name="com.iamplus.onenumber.device"/>
</intent-filter>
</receiver>
</application>
</manifest>
Module that will merge:
Gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
jniDebuggable true
}
}
}
dependencies {
compile project(path: ':android-infra')
compile 'com.sensiya:sense-services-client:1.24.2@aar'
compile project(path: ':engine-core-server')
compile project(path: ':engine-core-aneeda')
}
Manifest:
<manifest package="com.iamplus.android.senseServices"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application
tools:node="replace">
<service
android:name="com.iamplus.senseServices.ContextualEventService"
android:enabled="true"/>
<service
android:name="com.iamplus.senseServices.Serv"
android:enabled="true"/>
<service
android:name="com.iamplus.senseServices.Serv1"
android:enabled="true"/>
</application>
</manifest>
Any suggestions?
If you want to apply the merge rule markers to only a specific imported library, add the tools:selector attribute with the library package name. For example, with the following manifest, the remove merge rule is applied only when the lower-priority manifest file is from the com. example. lib1 library.
Android Manifest usually contains pre-defined or static information which is then used to run the app. However, Android toolchain provides customization by allowing you to specify dynamic information through variable declaration, generally referred as Android Manifest placeholders.
The AndroidManifest. xml file contains information of your package, including components of the application such as activities, services, broadcast receivers, content providers etc.
It could be many things.Since you didn't provide code, I will guess you are using default merge behavior. For more information, see: Merge conflict heuristics
You can use Merged Manifest view to preview the results of your merged manifest and find conflict errors.
In general, merge by default should work. Then just use Merged Manifest view to see how & where you lost values during merging. Using Merge rule markers would help you to manage merge by assigning rules markers.
If there is no merge at all. so it's probably a dependency issue between modules.
Note that dependency order plays a crucial role with modules which have the same priority level, such as libraries.
--- Update 5.April.2017 ---
Here are some useful tips:
tools:node=”remove"
or tools:node="removeAll"
or in gradle( see
this Disable Manifest Merger in Android Gradle Build)--- Update(2) 5.April.2017 ---
After you had added code, I could see that you are using Attribute
tools:node="replace"
Under application element in your modules (and probably in app's manifest too). I think that is the reason why you didn't get any manifest merged from imported modules merged to your app's manifest. See tools:node="replace"
under Node markers.
Replace the lower-priority element completely. That is, if there is a matching element in the lower-priority manifest, ignore it and use this element exactly as it appears in this manifest.
That means both modules above will never get any thing merged with manifest from:
So get rid of that attribute and clean and rebuild modules. then rebuild whole project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With