Lilly
03/29/2022, 6:49 PMincludeBuild()
? keyword: Composite Builds. I have the case where
Project A (:app -> :anotherLibrary) -> Project B, Project B -> Project A (:library)
Project A modules:
:library
:app
Project B modules:
:anotherLibrary
There is also a common module which is used in both projects and this causes to gradle build to fail with an error:
Failed to get Gradle name for :commonAny ideas?
Vampire
03/29/2022, 6:56 PMa1
from A
depends on b
from B
and b
depends on a2
from A
, there should be no problem unless you introduce an actual cycle like a1
needs b1
which in turn needs a1
, that would be a problem of course.
I think I've never seen "Failed to get Gradle name", is that really the error message? Can you provide an MCVE?Lilly
03/29/2022, 7:01 PMLilly
03/29/2022, 7:05 PMLilly
03/29/2022, 7:31 PMprotocol
:app
:lib
data
:lib
common-android
:mylib
common-core
:lib
Dependencies:
settings.gradle.kts (protocol)
rootProject.name = "protocol"
include(":app")
include(":lib")
includeBuild("../data")
includeBuild("../common-android") // this is causing the fail: Failed to get Gradle name for :mylib
settings.gradle.kts (data)
rootProject.name = "data"
include(":lib")
includeBuild("../protocol")
settings.gradle.kts (common-android)
rootProject.name = "common-android"
include(":mylib")
includeBuild("../common-core")
Vampire
03/29/2022, 7:53 PMVampire
03/29/2022, 8:04 PMprotocol
project in IntelliJ.
Sync worked fine and has all 4 projects present.Lilly
03/29/2022, 8:06 PMbash gradlew
? Or is there a task for the sync process which I could execute?Vampire
03/29/2022, 8:07 PMVampire
03/29/2022, 8:08 PMVampire
03/29/2022, 8:08 PMLilly
03/29/2022, 8:26 PMcommon-android
project fails with following error:
* What went wrong:
Execution failed for task ':mylib:compileDebugJavaWithJavac'.
> Could not resolve all files for configuration ':mylib:androidJdkImage'.
> Failed to transform core-for-system-modules.jar to match attributes {artifactType=_internal_android_jdk_image, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Execution failed for JdkImageTransform: /home/user/dev/android/sdk/platforms/android-32/core-for-system-modules.jar.
> jlink executable /usr/lib/jvm/java-17-openjdk/bin/jlink does not exist.
I can't find this relation. I have removed the .idea folder but with no luck. Do you know whats the problem is?
EDIT:
I'm using the embedded JDK for all projects.Vampire
03/29/2022, 8:28 PMLilly
03/29/2022, 8:29 PMVampire
03/29/2022, 9:20 PMjlink
also might not adhere to that, but use the Java you run Gradle with, I don't know.
No core Gradle code I know of uses jlink
.Lilly
03/29/2022, 10:22 PMLilly
03/30/2022, 5:43 AMAlso, what you provided works fine here.
Sync worked fine and has all 4 projects present.So that matter didn't let me rest. I have prepared a MCVE. I also tried it under Windows 11 but with no luck, same error message. Could you please have a look into this.
Vampire
03/30/2022, 8:31 AMLilly
03/30/2022, 1:28 PMLilly
03/30/2022, 6:14 PMdata
project when protocol
includes common-android
and data
in turn includes protocol. Isn't it possible to only include protocol without its composite builds so that sync does not even try to load common-android
?
settings.gradle.kts (data)
rootProject.name = "data"
include(":lib")
includeBuild("../protocol") // somehow load only protocol without its composite builds
What would you do?Vampire
03/30/2022, 6:19 PMidea.sync.active
and only include the build if it is not set to true
Lilly
03/30/2022, 7:16 PMdata settings.gradle.kts
if (System.getProperty("idea.sync.active") != "true") {
includeBuild("../protocol")
includeBuild("../common-core")
}
data:lib build.gradle.kts
dependencies {
implementation("protocol:lib")
implementation("common-core:lib")
}
Failed to resolve: protocol:lib
Failed to resolve: common-core:libIn turn I also cannot access the code base of protocol. The command line build runs successfully.
Vampire
03/30/2022, 7:34 PMVampire
03/30/2022, 7:34 PMVampire
03/30/2022, 7:34 PMLilly
03/31/2022, 10:55 AM* What went wrong:
Execution failed for task 'applintAnalyzeDebug'.
> java.lang.NullPointerException (no error message)It occurs when I execute
gradlew build
on command line in a fresh android project while common-android
is included + its nested build is set as dependency (common-core), i.e.
settings.gradle.kts
includeBuild("../dccommon-android")
:app build.gradle.kts
dependencies {
implementation("common-core:common") // error occurs when this dep is set. It's a nested composite build: common-android includes common-core
implementation("common-android:common") // this works, no lint error on build
}
What do you think? Might this be a bug?Vampire
03/31/2022, 10:58 AMNullPointerException
that happens is a bug.
Either that the used thing is null
, or that the caller does not check for null
.
So imho you should anyway report it to Google.Lilly
03/31/2022, 11:03 AM