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

后端 未结 1 2017
面向向阳花
面向向阳花 2021-02-03 11:16

Here is my development project structure:

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

MyLib depends on LibA

相关标签:
1条回答
  • 2021-02-03 11:53

    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?

    0 讨论(0)
提交回复
热议问题