How to release an AAR with another android library project dependency?

Here is my development project structure:

projectFolder
  |
  +--App
  |
  +--MyLib
  |
  +--Libraries
      |
      +--LibA

MyLib depends on LibA, I have packaged MyLib as an AAR and release it to a Maven repo, But when I include MyLib in another project(TestProj) as a remote aar dependency, I get build error(can’t resolve dependency of LibA, LibA is not included with the release of MyLib),
This is the build.gradel in app folder of TestProj:

  • In app billing security
  • Multiple alignment in TextView?
  • Android: keeping a background service alive (preventing process death)
  • Inflated ImageView to put in GalleryView isn't the right size
  • How to know which intent is selected in Intent.ACTION_SEND?
  • How to set the focus on the last element in a list view in android
  • dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile ('xxx.xxxxxx:yyyyy:1.0-SNAPSHOT@aar'){
          transitive = true
      }
    }
    

    And here is the build.gradle of MyLib:

    dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
      compile project(':Libraries:LibA')
    }
    

    How can I release MyLib with LibA already packaged in the AAR?

    Related posts:

    How to get file read line by line
    get location without google play services -android
    Converting preview frame to bitmap
    Position of DialogFragment in Android
    How to display a one time welcome screen?
    Google Cloud Messaging registration id expiration
  • What is the unit of bitmap.getWidth() or bitmap.getHeight()
  • Create new Gradle based Android project in IntelliJ IDEA
  • ButterKnife not working with Jack?
  • Secure HTTP Post in Android
  • Gradle failed to resolve library in Android Studio
  • Calling REST API from an android app
  • One Solution collect form web for “How to release an AAR with another android library project dependency?”

    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?

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.