Fix indexing bug when config.Arches() returns an empty array.

This happens when com.android.art.host is not disabled in
prebuilts/build-tools/build-prebuilts.sh.

Test: m nothing
Test: env OUT_DIR=out prebuilts/build-tools/build-prebuilts.sh
  on the aosp-build-tools branch
Bug: 188922057
Change-Id: Ib21d17bb627e4cf7faee320febe65e1bb4566d4e
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 68182a7..364013f 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -7589,6 +7589,28 @@
 	}
 }
 
+func TestHostApexInHostOnlyBuild(t *testing.T) {
+	testApex(t, `
+		apex {
+			name: "myapex",
+			host_supported: true,
+			key: "myapex.key",
+			updatable: false,
+			payload_type: "zip",
+		}
+		apex_key {
+			name: "myapex.key",
+			public_key: "testkey.avbpubkey",
+			private_key: "testkey.pem",
+		}
+	`,
+		android.FixtureModifyConfig(func(config android.Config) {
+			// We may not have device targets in all builds, e.g. in
+			// prebuilts/build-tools/build-prebuilts.sh
+			config.Targets[android.Android] = []android.Target{}
+		}))
+}
+
 func TestMain(m *testing.M) {
 	os.Exit(m.Run())
 }