Use AIDL interfaces across module/subprojects in Gradle
I found a solution. There is an apparently undocumented feature in Android gradle build tools to include arbitrary aidl files into the output .aar file. This makes it possible to reference them in other subprojects.
// In modA build.gradle
android {
aidlPackageWhiteList "src/main/aidl/foo.aidl"
}
This is far from ideal, but at least usable to solve my problem.
EDIT: Clarify that this would be in modA (the library), not modB (which is a library according to the question, but not in all possible cases).