Class PostValidator

java.lang.Object
com.android.manifmerger.PostValidator

public class PostValidator extends Object
Validator that runs post merging activities and verifies that all "tools:" instructions triggered an action by the merging tool.

This is primarily to catch situations like a user entered a tools:remove="foo" directory on one of its elements and that particular attribute was never removed during the merges possibly indicating an unforeseen change of configuration.

Most of the output from this validation should be warnings.

  • Constructor Details

    • PostValidator

      public PostValidator()
  • Method Details

    • validate

      public static void validate(@NonNull XmlDocument xmlDocument, @NonNull MergingReport.Builder mergingReport)
      Post validation of the merged document. This will essentially check that all merging instructions were applied at least once.
      Parameters:
      xmlDocument - merged document to check.
      mergingReport - report for errors and warnings.
    • enforceToolsNamespaceDeclaration

      protected static void enforceToolsNamespaceDeclaration(@NonNull XmlDocument xmlDocument)
      Enforces SdkConstants.TOOLS_URI declaration in the top level element, if necessary. It is possible that the original manifest file did not contain any attribute declaration, therefore not requiring a xmlns: declaration. Yet the implicit elements handling may have added attributes requiring the namespace declaration.