3

In 10 minutes, I created an empty android library and an empty android application in this git repository

https://github.com/deanhiller/compositeAndroid

As seen in my last commit, I quickly convert the android application do depend on the library via gradle's awesome composite build feature (We use this feature a TON in our monorepo so loading a project loads all the libraries source code that it uses as well). Our library is shared amongst a few projects.

I cd into compositeAndroid/MyApplication and run ./gradlew build and it fails with

* What went wrong:
Could not determine the dependencies of task ':app:mergeReleaseAssets'.
> Could not resolve all task dependencies for configuration ':app:releaseRuntimeClasspath'.
> Could not resolve com.tray.android:MyLib.
 Required by:
     project :app
  > No matching configuration of project :MyLib was found. The consumer was configured to find a runtime of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '7.1.0' but:
      - None of the consumable configurations have attributes.

I am not sure how to work around this. I have a work around to publish/consume but would much prefer composite builds as it brings the source of libraries into intellij cleanly.

Why is composite builds not working? Is there something special I have to do for android projects? The above repo I setup in 10 minutes with those 2 projects(brand new).

You can always clone and play with it yourself as well. (We will actually be releasing our monorepo open-source template however it is not working to well with android just yet).

Dean Hiller
  • 19,235
  • 25
  • 129
  • 212

1 Answers1

0

After looking into the code under MyLib folder in the repository you shared here - it seems you've opened a regular project and intend to use it as a library

Can you please follow the steps required here and test it under a new module?

Hint: your build should result with an aar file

ymz
  • 6,602
  • 1
  • 20
  • 39
  • huh? @ymz I did the EXACT steps in "Convert an app module to a library module" on the link you gave to create MyLib. It was executed off that perfectly so I am very confused by your answer. – Dean Hiller Sep 05 '22 at 15:34
  • as far as I concerned your `gradle.build` file should contain only ` id 'com.android.library'` under `plugins` section.. in your case it contains both `library` and `application`... maybe it's best to open a new module (from scratch) transfer your code and ensure the build results with an `aar` file – ymz Sep 05 '22 at 19:35