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?
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 are getting manifest merge conflicts you have two options.
1) find all the manifest files included in your project including the ones in libraries that you have as dependencies, and ensure there are no conflicting configurations.
or 2) add some merge resolution rules to your Manifests to dictate how each conflict should be resolved.
There is a great page on that here with many details.
https://developer.android.com/studio/build/manifest-merge.html
From Android Studio
Build ---> Clean project
then
Build --> Make Project
This should help fix
I had a similar problem for Unity. I was able to solve it by going on the SDK Manager and removing the latest android api. Then I installed a slightly older api and it worked (API 21 or 22 I think)
I recently have same problem in my production code. Having one libraries into app module exists also in other Gradle Dependency causes the duplicate entries. We need to exclude such module or libraries from conflicted one.
For that we must know number of libraries used by a particular Gadle dependency.
Consider a case where I using "bolts-android-1.2.0.jar" in my app gradle. In same gradle I m using facebookSDK as below.
compile('com.facebook.android:facebook-android-sdk:4.5.0')
So I have to exclude "bolts-android" as below
compile('com.facebook.android:facebook-android-sdk:4.5.0') {
exclude module: 'bolts-android'
}
So how to know that facebookSDK uses "bolts-android"
Here you can use plugin Android Method Count
Seems like the problem is from using tools:node="replace"
in the application
element. From the documentation :
...if there is a matching element in the lower-priority manifest, ignore it and use this element exactly as it appears in this manifest.
What you actually want to use is tools:node="merge"
which is the default behavior.
Merge all attributes in this tag and all nested elements when there are no conflicts using the merge conflict heuristics. This is the default behavior for elements.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.