:lib1 is an Android module which has something declared in src/debug/java/.
:lib2 is an Android module with a testImplementation dependency upon :lib1, and it's only referencing that code which is defined ini debug.
ModuleCheck will currently say that's an unused dependency.
Android test and androidTest automatically target debug source sets for variant merging, even in dependencies. (docs)