I have a project setup with two android libraries,...
# multiplatform
t
I have a project setup with two android libraries, one depends on the other, when I try to publish, I run into an error. Any pointers where to go? Details about Gradle config in the thread.
Copy code
Execution failed for task ':adaptive-ui:adaptive-ui-common:generatePomFileForAndroidDebugPublication'.
> Could not apply withXml() to generated POM
   > The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.0', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'. However we cannot choose between the following variants of project :adaptive-core:
       - Configuration ':adaptive-core:debugApiElements' variant android-classes-jar declares a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.2.0', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm':
           - Unmatched attributes:
               - Provides attribute 'artifactType' with value 'android-classes-jar' but the consumer didn't ask for it
               - Provides attribute 'com.android.build.gradle.internal.attributes.VariantAttr' with value 'debug' but the consumer didn't ask for it
               - Provides its elements packaged as a jar but the consumer didn't ask for it
Both libraries are configured like this:
Copy code
androidTarget {
    publishLibraryVariants("release", "debug")
    @OptIn(ExperimentalKotlinGradlePluginApi::class)
    compilerOptions.jvmTarget.set(JvmTarget.JVM_11)
}
Core library: https://github.com/spxbhuhb/adaptive/blob/5f0f4f05a37395a5cb45574cfc9d3cd38b991395/adaptive-core/build.gradle.kts UI library (depends on the core): https://github.com/spxbhuhb/adaptive/blob/5f0f4f05a37395a5cb45574cfc9d3cd38b991395/adaptive-ui/adaptive-ui-common/build.gradle.kts
The publication worked before I've added
androidTarget
to the core libary.
p
if you try depending in this way
api(project(":adaptive-core"))
something changes? - using the old notation
t
This is a composite build, so I cannot change that easily. It might be possible that this simply won't work with a composite build, in that case I'll just move the code into the second library and remove the android target from the first.
p
Ah ok I see, just a suspicion because it is the only thing I see different to other projects.
t
better to ask in #gradle such questions. Also please share a Gradle build scan with error
t
Thanks for the suggestion. Actually I moved the android part to the second library and simply removed the android target from the core. I haven't spent too much time on the issue, it's about the POM files and Gradle docs says that with composite build it might simply not work.
👌 1
👍 1
159 Views