Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default value for manifestPlaceholder

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.

like image 302
Coldfish Avatar asked Nov 13 '17 12:11

Coldfish


People also ask

What is manifest placeholder?

xml file in the directory structure. Android Manifest usually contains pre-defined or static information which is then used to run the app. However, Android toolchain provides customization by allowing you to specify dynamic information through variable declaration, generally referred as Android Manifest placeholders.

How do I edit Android manifest?

The Android manifest file is a specially formatted XML file. You can edit the XML manually by clicking on the AndroidManifest. xml tab. Android manifest files generally include a single <manifest> tag with a single <application> tag.

How do you do merged manifest?

Inspect the merged manifest and find conflicts Even before you build your app, you can see a preview of what your merged manifest looks by opening your AndroidManifest. xml file in Android Studio, and then clicking the Merged Manifest tab at the bottom of the editor.

What is manifest file in Android?

The manifest file describes essential information about your app to the Android build tools, the Android operating system, and Google Play.


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

like image 68
Nicolás Carrasco-Stevenson Avatar answered Oct 12 '22 22:10

Nicolás Carrasco-Stevenson