Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

manifest merger failed when the same library is imported in 2 feature modules

I am running into a build issue where gradle complains about "getMergedManifest failed manifest merger failed"

the error in the log shows lines like:

WARN - .tools.idea.model.ManifestInfo - getMergedManifest failed Manifest merger failed : Attribute provider#com.google.firebase.provider.FirebaseInitProvider@authorities value=(com.xxxxxxxxxx.feature_team.firebaseinitprovider) from AndroidManifest.xml:10:13-72
is also present at AndroidManifest.xml:36:559-633 value=(com.xxxxxxxxx.base.firebaseinitprovider).
Suggestion: add 'tools:replace="android:authorities"' to <provider> element at AndroidManifest.xml:8:9-12:39 to override.

What am i suppose to do here? I don't have any authorities section in any of my manifest files. The error arrives when in 2 feature modules the same shared library is imported which in result is depending on some google libs. I am sure that all versions of external libs are the same. Anyone knows how to solve this?

------- edit. Still got errors ------.

......./base/src/main/AndroidManifest.xml:70:13-46 Error:
    Attribute activity#com.facebook.LoginActivity@splitName value=(feature_match) from [:feature_match] AndroidManifest.xml:70:13-46
    is also present at [:feature_topvoters] AndroidManifest.xml:73:13-50 value=(feature_topvoters).

    Suggestion: add 'tools:replace="android:splitName"' to <activity> 
element at AndroidManifest.xml:68:9-71:75 to override.

......./base/src/main/AndroidManifest.xml:74:13-46 Error:
    Attribute activity#com.github.gorbin.asne.core.OAuthActivity@splitName value=(feature_match) from [:feature_match] AndroidManifest.xml:74:13-46
    is also present at [:feature_topvoters] AndroidManifest.xml:77:13-50 value=(feature_topvoters).

    Suggestion: add 'tools:replace="android:splitName"' to <activity> element at AndroidManifest.xml:72:9-75:80 to override.

So basically the issue appears when i try to add the same library in both 2 feature modules. What do i need to tell the manifest to prevent this merge conflict. Both manifest files from the feature modules are empty. It must be the thirdparty manifest files causing the issue.

I thought the multiple feature/module structure would increase the architecture. But by now i really think it is way easier to have one big module. There are just too many issues in the whole gradle build model.

like image 314
Gillis Haasnoot Avatar asked Dec 29 '17 00:12

Gillis Haasnoot


1 Answers

Ok after 10 hours of trying to find a solution i came up with the following:

I cloned the library causing the issue (Facebook). Instead of compiling against maven i created a new library and put the complete source of the facebook SDK inside. Inside the manifest.xml from that facebook SDK, there is an activity defined:

<activity
        tools:replace="android:theme"
        android:name="com.facebook.LoginActivity"
        android:theme="@android:style/Theme.Translucent.NoTitleBar"
        />

I removed the activity from the manifest.xml and moved the activity definition into the main app manifest.xml In this way the manifest merger will not try to merge two of the same activity definitions, but uses the one defined in the main app. Works. But it is a shitty solution of course. Not sure if this a bug in the build process. I have spend over 20 hours trying to fix this. Cannot find a way. Multi module applications are not easy to construct.

like image 168
Gillis Haasnoot Avatar answered Nov 14 '22 22:11

Gillis Haasnoot