AAPT2: Add validation for SDK version strings.

Ensure that the configured min max and target SDK versions of the
android-sdk configuration item are correct. This will prevent AAPT2
crashing when it tries to dereference the Android SDK version to update
the manifest.

The test for the latest development SDK version has also been made
future proof by using the SDK constants.

Test: unit tests
Test: manually split an APK
Change-Id: I1ffa90ba2d96cab0cbfa4bd75ef37a50d986852d
diff --git a/tools/aapt2/configuration/ConfigurationParser.cpp b/tools/aapt2/configuration/ConfigurationParser.cpp
index b99240f..852ff17 100644
--- a/tools/aapt2/configuration/ConfigurationParser.cpp
+++ b/tools/aapt2/configuration/ConfigurationParser.cpp
@@ -519,14 +519,22 @@
     } else {
       AndroidSdk entry;
       for (const auto& attr : child->attributes) {
+        Maybe<int>* target = nullptr;
         if (attr.name == "minSdkVersion") {
-          entry.min_sdk_version = ResourceUtils::ParseSdkVersion(attr.value);
+          target = &entry.min_sdk_version;
         } else if (attr.name == "targetSdkVersion") {
-          entry.target_sdk_version = ResourceUtils::ParseSdkVersion(attr.value);
+          target = &entry.target_sdk_version;
         } else if (attr.name == "maxSdkVersion") {
-          entry.max_sdk_version = ResourceUtils::ParseSdkVersion(attr.value);
+          target = &entry.max_sdk_version;
         } else {
           diag->Warn(DiagMessage() << "Unknown attribute: " << attr.name << " = " << attr.value);
+          continue;
+        }
+
+        *target = ResourceUtils::ParseSdkVersion(attr.value);
+        if (!*target) {
+          diag->Error(DiagMessage() << "Invalid attribute: " << attr.name << " = " << attr.value);
+          valid = false;
         }
       }