Merge "Fix a bug where disbled modules generating error messages." into main
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)