Revert^2 "Don't depend on nonexistent manifest when manifest_check is disabled."

Reason for revert: relanding original change. The fix was to add AAPT to
the dependencies of the failed command. It didn't fail in AOSP, and on
some targets in sc-dev, because the build order happened to be different
and AAPT was built by the time it was needed. This also explains why
some builds oscillated between red and green.

Reverted Changes:
I52f00c9f4:Revert "Don't depend on nonexistent manifest when ...
I4c2d4e1c7:Revert "Reimplement verify_uses_libraries.sh in ma...
Ibebd616a7:Revert "Reimplement verify_uses_libraries.sh in ma...

Bug: 132357300
Bug: 183010666
Change-Id: I28b20308f4d68185af8ec15407b35ded1aaa2eb0
Test: treehugger
Test: forrest on git_sc-dev target aosp_blueline-userdebug
diff --git a/java/app.go b/java/app.go
index 3ef31d5..1b6e0e3 100755
--- a/java/app.go
+++ b/java/app.go
@@ -1286,7 +1286,7 @@
 // an APK with the manifest embedded in it (manifest_check will know which one it is by the file
 // extension: APKs are supposed to end with '.apk').
 func (u *usesLibrary) verifyUsesLibraries(ctx android.ModuleContext, inputFile android.Path,
-	outputFile android.WritablePath) {
+	outputFile android.WritablePath) android.Path {
 
 	statusFile := dexpreopt.UsesLibrariesStatusFile(ctx)
 
@@ -1295,7 +1295,7 @@
 	// non-linux build platforms where dexpreopt is generally disabled (the check may fail due to
 	// various unrelated reasons, such as a failure to get manifest from an APK).
 	if dexpreopt.GetGlobalConfig(ctx).DisablePreopt {
-		return
+		return inputFile
 	}
 
 	rule := android.NewRuleBuilder(pctx, ctx)
@@ -1322,14 +1322,14 @@
 	}
 
 	rule.Build("verify_uses_libraries", "verify <uses-library>")
+	return outputFile
 }
 
 // verifyUsesLibrariesManifest checks the <uses-library> tags in an AndroidManifest.xml against
 // the build system and returns the path to a copy of the manifest.
 func (u *usesLibrary) verifyUsesLibrariesManifest(ctx android.ModuleContext, manifest android.Path) android.Path {
 	outputFile := android.PathForModuleOut(ctx, "manifest_check", "AndroidManifest.xml")
-	u.verifyUsesLibraries(ctx, manifest, outputFile)
-	return outputFile
+	return u.verifyUsesLibraries(ctx, manifest, outputFile)
 }
 
 // verifyUsesLibrariesAPK checks the <uses-library> tags in the manifest of an APK against the build