Fix a bug where disbled modules generating error messages.

Bug: 390254600
Test: Local and adbt
Change-Id: If5f35e47dde8fa159e802bad9104052d4ef1bb2e
diff --git a/java/app.go b/java/app.go
index f4c658c..34a172e 100644
--- a/java/app.go
+++ b/java/app.go
@@ -1171,6 +1171,9 @@
 	seenModulePaths := make(map[string]bool)
 
 	ctx.WalkDepsProxy(func(module, parent android.ModuleProxy) bool {
+		if !android.OtherModuleProviderOrDefault(ctx, module, android.CommonModuleInfoKey).Enabled {
+			return false
+		}
 		otherName := ctx.OtherModuleName(module)
 		tag := ctx.OtherModuleDependencyTag(module)