问题
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?
回答1:
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
回答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)
来源:https://stackoverflow.com/questions/51338009/android-studio-instant-app-manifest-merging-error