jhiertz
07/15/2024, 7:27 AM// build.gradle.kts (Module :android Project 1)
implementation("projectB:version")
// settings.gradle.kts (Project A)
includeBuild(path_to_projectB) {
dependencySubstitution {
substitute(module("projectB")).using(project(":android_sdk"))
}
}
In my project B I had a single module :android_sdk and everything worked fine. While I'm developing, I can see projects A and B in Android Studio and make modifications, then when I create a release, it uses the version published on a maven. Where things get complicated is when I try to create modules in Project B, I can't use them in Project A.
I tried to include it this way but got an error in the projectB module "Plugin [id: 'com.android.library'] was nout found in any of the following sources
// build.gradle.kts (Module :android Project 1)
implementation(project(":core-util"))
// settings.gradle.kts (Projet A)
includeBuild("${path_to_projectB}/core-util")
If I have to summarize my tree structure, here it is:
Project A
├── build.gradle.kts
├── settings.gradle.kts
├── :android
├── build.gradle.kts
Project B
├── build.gradle.kts
├── settings.gradle.kts
├── :android_sdk
├── build.gradle.kts
├── :core-util
├── build.gradle.kts
I can't access the core-util module from project A even though I'm accessing the android_sdk module.Vampire
07/15/2024, 7:56 AMincludeBuild
the core-util
directory, it is a project not a build. Assuming you include
the core-util
inside the settings script of "Project B", then includeBuild
of "Project B" is the appropriate to do and enough. Optimally, you configure your projects in "Project B" properly, so that you do not need any substitution rules, then it just works ootb.jhiertz
07/15/2024, 9:57 AM// settings.gradle.kts
include(":android_sdk")
include(":core-util")
// build.gradle.kts
implementation(project(":core-util"))
But if I try to use a core-util method in project A, I get an Unresolved reference: method
and Android Studio suggests I add the core-util
module dependency.
When I add the dependency
implementation(project(":core-util"))
I get: org.gradle.api.UnknownProjectException: The project with path ':core-util' could not be found in project ':android'.
Vampire
07/15/2024, 10:09 AMproject(...)
, that only works within the same build. You need to use the coordinates.jhiertz
07/15/2024, 12:34 PMVampire
07/15/2024, 12:49 PMjhiertz
07/15/2024, 2:56 PM