Here is my development project structure:
projectFolder | +--App | +--MyLib | +--Libraries | +--LibA
MyLib depends on LibA
Answer the question myself. finally I changed the build.gradle in MyLib to:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
provided project(':Libraries:LibA')
}
so LibA will only be used in the build process of MyLib, TestProj will not ask for the LibA dependency anymore at compile time. NOTE THAT this may cause NoClassDefFoundError at runtime, so you must told the guys who used your library to include the LibA themselves in build.gradle of their project.
At first, I was looking for a method to package LibA with MyLib, but it seems diffcult.
See this question: Android Studio how to package single AAR from multiple library projects?