How to set default value for manifestPlaceholder

Viewed 945

I'm using the manifestPlaceholder tag in the build.gradle file for a library project.

The person who uses the library should define it properly.

AndroidManifest.xml in Library:

    <meta-data
        android:name="library_id"
        android:value="${libraryId}"/>

Build.gradle file on the application side:

        manifestPlaceholders = [libraryId: "example"]

Is there any option to override the manifestPlaceholder tag on the library side?

I just want to define a default value and user should be free to provide a value if he wants to change it.

1 Answers

Have you tried using a Manifest Merge strategy to get the desired effect?

On the app manifest you can add something like

<your-outer-element
    tools:node="replace">
        <meta-data 
            android:name="library_id"
            android:value="YOUR_APP_ID"/>
</your-outer-element>

And that will replace the library_id meta data found inside the your-outer-element found in the library Manifest

Related