Android Studio - Instant App - Manifest merging error
Asked Answered
J

2

6

I have problem with my Android Studio Instant App Project. If I select Manifest.xml in /app directory then select Merger Manifest then I have such error:

Merging Errors: Error: Attribute provider#android.arch.lifecycle.ProcessLifecycleOwnerInitializer@authorities value=(com.theminte.TheMinte.lifecycle-trojan) from AndroidManifest.xml:10:15-75 is also present at AndroidManifest.xml:25:13-68 value=(com.theminte.TheMinte.app.lifecycle-trojan). Suggestion: add 'tools:replace="android:authorities"' to <provider> element at AndroidManifest.xml:10:5-201 to override. app main manifest (this file), line 9

Than I cannot start my application with Default Activity, I can only start it with Nothing Activity selected in Project Build Configuration. How to solve this merging issue?

Japan answered 14/7, 2018 at 11:25 Comment(3)
can you please provide the code which is inside <application> tag of your Manifest file?Ovarian
Add the code of Manifest.xml fileJsandye
I found the issue there was the problem with manifest margin cause I have included implementation "android.arch.lifecycle:extensions:1.1.0" in 'feature' package and implementation "android.arch.lifecycle:extensions:1.1.1" in 'base' packageIncurvate
M
4

I was able to fix this by changing the <manifest package = ${package} in my base module's manifest.xml to match the project's applicationId.

It appears that androidx.lifecycle:lifecycle-process:2.0.0, a dependency of androidx.lifecycle:lifecycle-extensions:2.0.0, is injecting the provider into base module's manifest with the package defined in the manifest.xml. Per the provider code in lifecycle-extensions/manifest.xml, it looks like it's expected to be the applicationId defined in build.gradle. The provider xml is:

<provider
        android:name="androidx.lifecycle.ProcessLifecycleOwnerInitializer"
        android:authorities="${applicationId}.lifecycle-process"
        android:exported="false"
        android:multiprocess="true" />

The merged manifest in my base module was showing the above provider inserted with an android:authorities value matching the <manifest package:{package} in the base module's manifest.xml instead of the packageId from app/build.gradle.

In the application module I see the provider being injected with the applicationId listed in the application build.gradle. This creates a conflict since there are now two providers with the same android:name="androidx.lifecycle.ProcessLifecycleOwnerInitializer

Mckie answered 24/10, 2018 at 22:33 Comment(1)
Created issue with google for tracking: issuetracker.google.com/issues/118423386Mckie
W
-2

why did you decide that manifests from features and instant app module would be merged? In all examples, instant app module has the only Gradle build script, so no any sources/resources/manifest are not merge with other feature modules.

Default activity must be set in manifest in feature module (in base feature manifest for example)

Wensleydale answered 26/7, 2018 at 15:40 Comment(1)
Base modules of an instant app can have activities/manifests/intents and are often where the default activity might live. Source googlelabs (github.com/googlecodelabs/android-topeka/tree/multiModule). The app will have merge conflicts in the manifest when using databinding on multiple modules since the provider is injected on both features.Mckie

© 2022 - 2024 — McMap. All rights reserved.