gradle - Cannot find sub module for maven library

2019-08-28 09:53发布

问题:

I am trying to make an android library public on maven, this artifact contains another three modules, and each modules is an aar file, which means it has string, layout resources. The structure of the library A is:

+ Library A
   -- Module 1
   -- Module 2
   -- Module 3

And in build.gradle of library A, I include these three modules by using

compile project (:module1);
compile project (:module2);
compile project (:module3);

But when I use this library in new project's gradle, it cannot find all the submodules. The error message is:(assume all modules version is 1.0)

Could not find module1:1.0
Searched in the following locations:
  file:/Users/chan/Documents/AndroidSDK/sdk/extras/m2repository/project/modules/widgets/module1/1.0/module1-1.0.pom
  file:/Users/chan/Documents/AndroidSDK/sdk/extras/m2repository/project/modules/widgets/module1/1.0/module1-1.0.jar
  file:/Users/chan/Documents/AndroidSDK/sdk/extras/google/m2repository/project/modules/widgets/module1/1.0/module1-1.0.pom
  file:/Users/chan/Documents/AndroidSDK/sdk/extras/google/m2repository/project/modules/widgets/module1/1.0/module1-1.0.jar
  file:/Users/chan/Documents/AndroidSDK/sdk/extras/android/m2repository/project/modules/widgets/module1/1.0/module1-1.0.pom
  file:/Users/chan/Documents/AndroidSDK/sdk/extras/android/m2repository/project/modules/widgets/module1/1.0/module1-1.0.jar      
 https://maven.google.com/project/modules/widgets/module1/1.0/module1-1.0.pom
  https://maven.google.com/project/modules/widgets/module1/1.0/module1-1.0.jar
  https://maven.com/artifactory/libs-release-local/project/modules/widgets/module1/1.0/module1-1.0.pom
  https://maven.com/artifactory/libs-release-local/project/modules/widgets/module1/1.0/module1-1.0.jar
  https://repo1.maven.org/maven2/project/modules/widgets/module1/1.0/module1-1.0.pom
  https://repo1.maven.org/maven2/project/modules/widgets/module1/1.0/widgets-unspecified.jar

Same error for module2 and module3.

I dont know why it cannot find the modules.

The Library A is configured in new project:

compile ('LibraryA:1.0@aar') {
   transitive=true
}

The followings are what I have tried so far, with no luck:

  1. I have added mavenCentral(), mavenLocal() or jcenter() in reporsitories() but still no luck.
  2. Tried using fat-aar android https://github.com/adwiv/android-fat-aar on library. No luck.Same error
  3. Added flatDir in reporsitories, no luck

Any suggestions would be much appreciated!