Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composite build exception when adding a library module dependency from the second build #28357

Open
dimitar71 opened this issue Mar 5, 2024 · 6 comments
Labels
a:documentation Documentation content in:composite-builds including BuildIdentifier

Comments

@dimitar71
Copy link

Current Behavior

  1. I am having 2 Android projects in two folders next to each other as follow:

MyApplication
.. app Android application module
...... build.gradle
.. api - Android library module
...... build.gradle
.. settings.gradle

SharedLibraries
.. app Android application module
...... build.gradle
.. shared-library - Android library module
...... build.gradle
.. settings.gradle

  1. MyApplication/settings.gradle has includeBuild("../SharedLibraries").

  2. I want to have a SharedLibraries/shared-library dependency in MyApplication/api/build.gradle


When I add in MyApplication/api/build.gradle this line:
implementation(project(":SharedLibraries:shared-library"))

I get this exception

Build file '/Users/dimitar/AndroidStudioProjects/MyApplication/api/build.gradle.kts' line: 33
org.gradle.api.UnknownProjectException: Project with path ':SharedLibraries:shared-library' could not be found in project ':api'.
	at org.gradle.api.internal.project.DefaultProject.project(DefaultProject.java:692)
	at org.gradle.api.internal.project.DefaultProject.project(DefaultProject.java:685)
	at org.gradle.internal.service.scopes.DefaultProjectFinder.getProject(DefaultProjectFinder.java:33)

Attached is a screenshot of the project structure.

composite_build_project

Expected Behavior

Library module dependency from a includeBuild() project should be valid and used as expected.

Context (optional)

No response

Steps to Reproduce

Please open MyApplication project from Android Studio and try to File > Sync Project with Gradle Files.

Exception will be shown in Build window.

Here is the project zip - composite_build_exception.zip

Gradle version

8.6

Build scan URL (optional)

No response

Your Environment (optional)

Android Studio Iguana
Mac OS Sonoma 14.3.1

@ov7a
Copy link
Member

ov7a commented Mar 5, 2024

Your issue appears to be a question about how to use Gradle. They should be asked in a different channel, so we will close it. Your question might be answered in Gradle documentation or on our community Slack or forums. Find links to these resources on help.gradle.org.

If you think our analysis is wrong, please provide us with more detailed information explaining why.


You are supposed to use implementation("com.example.shared_library:1.0") instead of implementation(project(":SharedLibraries:shared-library")). See the documentation.

@ov7a ov7a closed this as not planned Won't fix, can't repro, duplicate, stale Mar 5, 2024
@ov7a ov7a added closed:question usage question or request for help in:composite-builds including BuildIdentifier and removed a:bug to-triage labels Mar 5, 2024
@dimitar71
Copy link
Author

dimitar71 commented Mar 5, 2024

I still think the issue lies in composite builds.

The documentation provides sample of using binary libraries (JAR, AAR) - Defining a composite build:

The my-utils multi-project build produces two Java libraries, number-utils and string-utils. The my-app build produces an executable using functions from those libraries.

The problem I am having is using the Android library module as code, not as JAR/AAR.

@ov7a
Copy link
Member

ov7a commented Mar 6, 2024

The problem I am having is using the Android library module as code, not as JAR/AAR.

Then try to include those projects in your build without composite builds, using regular include

@dimitar71
Copy link
Author

dimitar71 commented Mar 6, 2024

include() works only when modules are part of same project.

These modules are in two separate projects.

Composite builds include a separate build via includeBuild()

I would not post here unless I am really stuck.

I think this in issue with Gradle (or Android Gradle plugin).

Still nothing from Android team - https://issuetracker.google.com/issues/328115462.
And not that much in Gradle Community Slack channel - https://gradle-community.slack.com/archives/CAHSN3LDN/p1709760926133779.

No fun :(

@dimitar71
Copy link
Author

I stand corrected.
The issue is on my side, not a Gradle problem.

Adding group and version and using Maven coordinates solved it.

Thanks to the responds which nudged me to the right direction - https://gradle-community.slack.com/archives/CAHSN3LDN/p1709760926133779

@ov7a
Copy link
Member

ov7a commented Mar 7, 2024

@dimitar71 Sorry for misleading you. Glad you resolved the issue.

The comment in the thread is right: the documentation on the composite builds should be improved. Thus, I'm reopening this as a documentation issue.

@ov7a ov7a reopened this Mar 7, 2024
@ov7a ov7a added a:documentation Documentation content and removed closed:question usage question or request for help labels Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:documentation Documentation content in:composite-builds including BuildIdentifier
Projects
None yet
Development

No branches or pull requests

2 participants