AAPT2: Fix order-of-destruction crash

Make sure that users of StringPool are destroyed before
the StringPool itself.

Test: valgrind aapt2 optimize -o opt.apk out/target/common/obj/APPS/framework-res_intermediates/package-export.apk
Change-Id: I140c2d32f8449028976795d5d6865d83e1409b53
diff --git a/tools/aapt2/xml/XmlDom.h b/tools/aapt2/xml/XmlDom.h
index f1d0953..6950c30 100644
--- a/tools/aapt2/xml/XmlDom.h
+++ b/tools/aapt2/xml/XmlDom.h
@@ -128,8 +128,13 @@
 class XmlResource {
  public:
   ResourceFile file;
-  std::unique_ptr<xml::Node> root;
+
+  // StringPool must come before the xml::Node. Destructors are called in reverse order, and
+  // the xml::Node may have StringPool references that need to be destroyed before the StringPool
+  // is destroyed.
   StringPool string_pool;
+
+  std::unique_ptr<xml::Node> root;
 };
 
 /**