AAPT2: Fixed id parsing error

A previous change, editied the logic for parsing ids to allow for ids to
reference other ids. This change though caused a regression that made
ids in the form '<id name="name" />' cease to parse. This changes fixes
that regression.

Bug: 78513618
Test: Updated tests in ResourceParser_test.cpp
Change-Id: I3608bb764464e951a50910be55e199c6ec575d09
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp
index 19c6c31..7f48544 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -598,10 +598,13 @@
       // If no inner element exists, represent a unique identifier
       out_resource->value = util::make_unique<Id>();
     } else {
-      // If an inner element exists, the inner element must be a reference to
-      // another resource id
       Reference* ref = ValueCast<Reference>(out_resource->value.get());
-      if (!ref || ref->name.value().type != ResourceType::kId) {
+      if (ref && !ref->name && !ref->id) {
+        // A null reference also means there is no inner element when ids are in the form:
+        //    <id name="name"/>
+        out_resource->value = util::make_unique<Id>();
+      } else if (!ref || ref->name.value().type != ResourceType::kId) {
+        // If an inner element exists, the inner element must be a reference to another resource id
         diag_->Error(DiagMessage(out_resource->source)
                          << "<" << parser->element_name()
                          << "> inner element must either be a resource reference or empty");