rules_android icon indicating copy to clipboard operation
rules_android copied to clipboard

Manifest merger, applicationId and dependency issue

Open Kernald opened this issue 6 years ago • 2 comments

I'm trying to build a small app using Bazel,rules_kotlin and rules_jvm_external, depending on androidx.lifecycle:lifecycle-extensions (through maven_install).

This library comes with a manifest declaring a provider, which is using ${applicationId} as a placeholder - which should be replaced at merging time by the consuming application id.

I end up with this in the merged manifest:

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

where as with Gradle, the authority is (as expected) replaced by com.example.myapp.lifecycle-process. The fact that it isn't replaced results in a failure at installation time, as the authority is already present on the device. Everything else looks fine in the merged manifest. Am I missing something, or is this a bug in the manifest merging process?

Kernald avatar Oct 07 '19 19:10 Kernald

I just tried adding this to my android_binary rule:

    manifest_values = {
        "applicationId": "com.example.myapp",
    },

With that, the merged manifest correctly replaces the applicationId in the provider authorities. I was assuming that the manifest merger would extract it from the manifest package, but it turns out it doesn't. I'm actually not sure if it's a bug or WAI, https://docs.bazel.build/versions/master/be/android.html#android_binary.manifest_values is not entirely clear to me.

Kernald avatar Oct 25 '19 09:10 Kernald

I came across this same problem. I'm using Java, no Kotlin, but linking to the android lifecycle libraries. Adding the manifest_values worked, but wondering if this is WAI?

marup avatar Dec 23 '19 00:12 marup