Class ManifestMerger2

java.lang.Object
com.android.manifmerger.ManifestMerger2

@Immutable public class ManifestMerger2 extends Object
merges android manifest files, idempotent.
  • Field Details

  • Method Details

    • setManifestAndroidAttribute

      public static String setManifestAndroidAttribute(@NonNull XmlDocument document, @NonNull String attribute, @NonNull String value)
      Set an android namespaced attribute for the manifest element.
      Parameters:
      document - the document whose attributes will be modified
      attribute - the new attribute to be set
      value - the new value of the attribute
      Returns:
      the previous value of the attribute or null if the attribute was not set.
    • setAndroidAttribute

      public static void setAndroidAttribute(XmlElement node, String localName, String value)
      Set an Android-namespaced XML attribute on the given node.
      Parameters:
      node - Node in which to set the attribute; must be part of a document
      localName - Non-prefixed attribute name
      value - value of the attribute
    • getChildElementsByName

      @NonNull public static com.google.common.collect.ImmutableList<Element> getChildElementsByName(@NonNull Element element, @NonNull String name)
      Returns a list of elements which are the immediate children of the given element and have the given name.
      Parameters:
      element - the immediate parent of any elements in the returned list
      name - the name of any elements in the returned list
      Returns:
      the list (possibly empty) of children elements with the given name
    • getFileStreamProvider

      @NonNull public ManifestMerger2.FileStreamProvider getFileStreamProvider()
      Returns the ManifestMerger2.FileStreamProvider used by this manifest merger. Use this to read files if you need to access the content of a XmlDocument.
    • newMerger

      @NonNull public static ManifestMerger2.Invoker newMerger(@NonNull File mainManifestFile, @NonNull com.android.utils.ILogger logger, @NonNull ManifestMerger2.MergeType mergeType)
      Creates a new ManifestMerger2.Invoker instance to invoke the merging tool to merge manifest files for an application.
      Parameters:
      mainManifestFile - application main manifest file.
      logger - the logger interface to use.
      Returns:
      an ManifestMerger2.Invoker instance that will allow further customization and trigger the merging tool.
    • performSystemPropertiesInjection

      protected void performSystemPropertiesInjection(@NonNull MergingReport.Builder mergingReport, @NonNull XmlDocument xmlDocument)
      Perform ManifestSystemProperty injection.
      Parameters:
      mergingReport - to log actions and errors.
      xmlDocument - the xml document to inject into.