Use LateStaticLibs for ndk_libandroid_support

This will obsolete the workaround in prebuilts/ndk/Android.bp to
export the ndk_libandroid_support headers from ndk_libc++_shared,
which would no longer have worked after the next patch.

Test: m checkbuild
Test: TestIncludeDirectoryOrdering
Change-Id: I9b4e5799d939433da547661b862e9db5a4aacb09
diff --git a/cc/cc_test.go b/cc/cc_test.go
index eaccfac..2d0d78b 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -4371,8 +4371,8 @@
 		"libarm",
 		"lib32",
 		"libandroid_arm",
-		"defaults/cc/common/ndk_libandroid_support",
 		"defaults/cc/common/ndk_libc++_shared",
+		"defaults/cc/common/ndk_libandroid_support",
 		"out/soong/ndk/sysroot/usr/include",
 		"out/soong/ndk/sysroot/usr/include/arm-linux-androideabi",
 		"${config.NoOverrideClangGlobalCflags}",
diff --git a/cc/stl.go b/cc/stl.go
index 75921c6..06dc840 100644
--- a/cc/stl.go
+++ b/cc/stl.go
@@ -199,7 +199,9 @@
 			deps.StaticLibs = append(deps.StaticLibs, stl.Properties.SelectedStl, "ndk_libc++abi")
 		}
 		if needsLibAndroidSupport(ctx) {
-			deps.StaticLibs = append(deps.StaticLibs, "ndk_libandroid_support")
+			// Use LateStaticLibs for ndk_libandroid_support so that its include directories
+			// come after ndk_libc++_static or ndk_libc++_shared.
+			deps.LateStaticLibs = append(deps.LateStaticLibs, "ndk_libandroid_support")
 		}
 		deps.StaticLibs = append(deps.StaticLibs, "ndk_libunwind")
 	default: