Am unable to get around this error after upgrading flutter version to 3.0.4. from version 2.10
Error
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':qr_code_scanner'.
> Could not resolve all artifacts for configuration ':qr_code_scanner:classpath'.
> Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10.
Required by:
project :qr_code_scanner
> The consumer was configured to find a runtime of a component compatible with Java 11, packaged as a jar, and its dependencies declared externally. However we cannot choose between the following variants of org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10:
- gradle70JavadocElements
- gradle70RuntimeElements
- gradle70SourcesElements
- javadocElements
- runtimeElementsWithFixedAttribute
- sourcesElements
All of them match the consumer attributes:
- Variant 'gradle70JavadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides javadocs but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'gradle70RuntimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Unmatched attributes:
- Provides a library but the consumer didn't ask for it
- Provides attribute 'org.gradle.jvm.environment' with value 'standard-jvm' but the consumer didn't ask for it
- Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'gradle70SourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides sources but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'javadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides javadocs but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides release status but the consumer didn't ask for it
- Variant 'runtimeElementsWithFixedAttribute' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Unmatched attributes:
- Provides a library but the consumer didn't ask for it
- Provides attribute 'org.gradle.jvm.environment' with value 'standard-jvm' but the consumer didn't ask for it
- Provides release status but the consumer didn't ask for it
- Variant 'sourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a runtime of a component, and its dependencies declared externally:
- Unmatched attributes:
- Provides documentation but the consumer didn't ask for it
- Provides sources but the consumer didn't ask for it
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about its elements (required them packaged as a jar)
- Provides release status but the consumer didn't ask for it
The following variants were also considered but didn't match the requested attributes:
- Variant 'apiElementsWithFixedAttribute' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
- Variant 'gradle70ApiElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
> Failed to notify project evaluation listener.
> Could not get unknown property 'android' for project ':qr_code_scanner' of type org.gradle.api.Project.
> Could not get unknown property 'android' for project ':qr_code_scanner' of type org.gradle.api.Project.
I dont understand where the issue is. Any assistance will be much appreciated
gradle file
buildscript {
ext.kotlin_version = '1.5.10'
repositories {
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.4' // Google Services plugin
}
}
allprojects {
repositories {
google()
jcenter()
}
}
Flutter doctor output
[√] Flutter (Channel stable, 3.0.4, on Microsoft Windows [Version 10.0.19044.1889], locale en-us)
[√] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[√] Chrome - develop for the web
[√] Android Studio (version 2021.2)
[√] VS Code (version 1.67.0)
[√] Connected device (3 available)
[√] HTTP Host Availability
i have tried changing kotlin versions manually but didn't work, also tried building the app from clean workstation and got the same error, reduced the qr scanner version from 4.0 to 1.0 but no fruits
This will work :)
ext.kotlin_version = '1.7.10'
classpath 'com.android.tools.build:gradle:4.2.0'
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
Related
After updating my Android Studio to the latest version i.e. Electric Eel | 2022.1.1, I got "Gradle project sync failed" after creating a new project.
Error:
A problem occurred configuring root project 'BIAssignment'.
> Could not resolve all files for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:7.4.0.
Required by:
project : > com.android.application:com.android.application.gradle.plugin:7.4.0
project : > com.android.library:com.android.library.gradle.plugin:7.4.0
> No matching variant of com.android.tools.build:gradle:7.4.0 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.5' but:
- Variant 'apiElements' capability com.android.tools.build:gradle:7.4.0 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
- Variant 'javadocElements' capability com.android.tools.build:gradle:7.4.0 declares a runtime of a component, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
- Variant 'runtimeElements' capability com.android.tools.build:gradle:7.4.0 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
- Variant 'sourcesElements' capability com.android.tools.build:gradle:7.4.0 declares a runtime of a component, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
I have already tried Invalidating Cache and changing Gradle version from Project Structure but neither of them worked. I also tried disabling Flutter plugin, but none of these methods work please help me solving this problem.
My current project structure:
build.gradle
plugins {
id 'com.android.application' version '7.4.0' apply false
id 'com.android.library' version '7.4.0' apply false
}
build.gradle
plugins {
id 'com.android.application'
}
android {
namespace 'com.biassignment'
compileSdk 33
defaultConfig {
applicationId "com.biassignment"
minSdk 24
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.navigation:navigation-fragment:2.5.3'
implementation 'androidx.navigation:navigation-ui:2.5.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
I solved the problem by changing the Android Gradle Plugin Version and Gradle Version.
File > Project Structure > Project
I changed this
to
Adding Fani comment:
Changing Gradle JDK to version 11 also worked for me.
File > Settings > Build, Execution, Deployment > Build Tools > Gradle.
Change the Gradle JDK to version 11.
Ok as I see all the thing is right just go to :
Project structure --> Modules
and change the Source $ Target compatibility from "$JavaVersion.VERSION_1_8" to "$JavaVersion.VERSION_11"
I ran into the same problem and applied the following solution :
I have changed the Gradle JDK to 11 and issue is resolved.
I had the same problem after upgrading Android Studio. You can reset Android Studio to its default state by following the instructions in the "Known Issues with Android Studio" page at section "Studio doesn't start after upgrade".
Reset Android Studio state: https://developer.android.com/studio/known-issues#studio-config-directories
Caution: All third-party plugins will be removed when you do this
By the way, changing the gradle version also worked for me (this answer).
I never answered a question before, please tell me if I'm missing something
Had the same error and upgraded to these Gradle settings
I also changed the Gradle JDK to:
After update Android Studio and create the first project I see:
A problem occurred configuring root project 'Demo Sample'.
Could not resolve all files for configuration ':classpath'.
Could not resolve com.android.tools.build:gradle:7.4.0-rc03.
Required by:
project : com.android.application:com.android.application.gradle.plugin:7.4.0-rc03
project : com.android.library:com.android.library.gradle.plugin:7.4.0-rc03
No matching variant of com.android.tools.build:gradle:7.4.0-rc03 was found. The consumer was configured to find a runtime of a library compatible with Java 8, packaged as a jar, and its dependencies declared externally, as well as attribute 'org.gradle.plugin.api-version' with value '7.5' but:
- Variant 'apiElements' capability com.android.tools.build:gradle:7.4.0-rc03 declares a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares an API of a component compatible with Java 11 and the consumer needed a runtime of a component compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
- Variant 'javadocElements' capability com.android.tools.build:gradle:7.4.0-rc03 declares a runtime of a component, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
- Variant 'runtimeElements' capability com.android.tools.build:gradle:7.4.0-rc03 declares a runtime of a library, packaged as a jar, and its dependencies declared externally:
- Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
- Other compatible attribute:
- Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
- Variant 'sourcesElements' capability com.android.tools.build:gradle:7.4.0-rc03 declares a runtime of a component, and its dependencies declared externally:
- Incompatible because this component declares documentation and the consumer needed a library
- Other compatible attributes:
- Doesn't say anything about its target Java version (required compatibility with Java 8)
- Doesn't say anything about its elements (required them packaged as a jar)
- Doesn't say anything about org.gradle.plugin.api-version (required '7.5')
I fixed:
Step 1, open notifications:
Step 2, click select the Gradle JDK Location
Step 3 Select Embedded JDK
I am working on a project which I used koin but I had the dependencies added from jcenter and not maven.
Since jcenter is going to get deprecated I want to transfer to maven.
So i removed Jcenter and I added mavenCentral().
The thing is that when i try to sync my project this error occures :
Could not resolve io.insert-koin:koin-androidx-scope:2.2.3.
Possible solution:
Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
Firstly, I followed the tutorial of insert-koin.io but nothing helped. When I try to press Run then the error of course still occurs.
Execution failed for task ':domain:compileKotlin'.
Could not resolve all files for configuration ':domain:compileClasspath'.
Could not resolve io.insert-koin:koin-androidx-scope:2.2.3.
Required by:
project :domain
> No matching variant of io.insert-koin:koin-androidx-scope:2.2.3 was found. The consumer was configured to find an API of a library compatible with Java 11, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm' but:
- Variant 'releaseApiPublication' capability io.insert-koin:koin-androidx-scope:2.2.3 declares an API of a library, and its dependencies declared externally:
- Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
- Other compatible attributes:
- Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
- Variant 'releaseRuntimePublication' capability io.insert-koin:koin-androidx-scope:2.2.3 declares a runtime of a library, and its dependencies declared externally:
- Incompatible because this component declares a component, with the library elements 'aar' and the consumer needed a component, preferably in the form of class files
- Other compatible attributes:
- Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
- Doesn't say anything about its target Java version (required compatibility with Java 11)
- Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'jvm')
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Does anybody have any idea what i should do ?
Still you should be able to use jcenter (read only) in gradle file if your artifacts not present in other repositories.
You should check the section in your build.gradle.
You need mavenCentral()
// Add Maven Central to your repositories if needed
repositories {
mavenCentral()
}
Add mavenCentral() if it is not in settings.gradle as below.
pluginManagement {
repositories {
...
mavenCentral()
}
If your impl is like implementation "org.koin:koin-android:$XX", replace it with implementation "io.insert-koin:koin-android:$koin_version" in app build.gradle.
Koin packages are now on maven central.
please refer to the new setup instructions for it
https://insert-koin.io/docs/setup/v3.2
So the gradle group name changed from org.koin to io.insert-koin
And here is an example :
implementation "io.insert-koin:koin-core:$koin_version"
I'm getting build errors in Android project caused by the following dependency:
implementation "com.algolia:instantsearch-android:2.5.1"
It helps to upgrade to 2.8.0 but I would prefer not since it requires minSdk 21.
Gradle 6.5
Android Gradle Plugin: 4.0.2
Kotlin 1.3.72
Could not determine the dependencies of task ':app:compileReleaseJavaWithJavac'.
> Could not resolve all task dependencies for configuration ':app:releaseCompileClasspath'.
> Could not resolve com.algolia:algoliasearch-client-kotlin-common:1.4.0.
Required by:
project :app > com.algolia:instantsearch-android:2.5.1
> No matching variant of com.algolia:algoliasearch-client-kotlin-common:1.4.0 was found. The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
- Variant 'metadata-api' capability com.algolia:algoliasearch-client-kotlin-common:1.4.0:
- Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'
- Other compatible attribute:
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'release')
I had a somewhat similar situation, but my case was slightly different than yours. I'll explain the difference between my situation and yours along with what I did to correct the situation. This might be a clue to your problem, but I'll leave it to you to see if it's applicable or helpful.
In my case, the error about incompatibility said that that the consumer had an attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' and that it found that my dependency had and attribute 'org.jetbrains.kotlin.platform.type' with value 'jvm'. Please note that I don't have the exact text and the message talked about other attributes and components. But when I parsed the message the obvious difference was the 'androidJvm' and 'jvm'.
What I did wrong, was that I was trying to add an android library dependency to a java library, and of course, that's not allowed. I had applied the 'java-library' plugin to the dependency instead of applying the 'com.android.plugin' to that library. I corrected that and the problem when away.
In your case, it looks like you have the difference 'common' versus 'androidJvm'. Unfortunately, I don't know what the platform type 'common' is referring to. It's probably due to the type of plugin you've got applied. Hopefully this helps you!
I uploaded a shared module from a Kotlin Multiplatform to JFrogs Artifactory. The goal is to use this shared module in another android app project and share business logic across projects.
I tried to only upload the android variant of the shared module - for the current purpose the iOS variant are not needed to be uploaded to artifactory.
I wrote this code in the build.gradle.kts of the shared module in the Kotlin Multiplatform project:
plugins {
kotlin("multiplatform")
id("com.android.library")
id("kotlin-android-extensions")
kotlin("plugin.serialization")
// plugins required for uploading to artifactory
id("maven-publish")
id("com.jfrog.artifactory") version "4.13.0"
}
.
.
.
artifactory {
setContextUrl("https://rbartifactory.jfrog.io/artifactory/")
publish(delegateClosureOf<PublisherConfig> {
repository(delegateClosureOf<DoubleDelegateWrapper> {
setProperty("repoKey", "App-Shared-Test-KMP")
setProperty("username", "<MY-USERNAME>")
setProperty("password", "<MY-USER-API-KEY>")
setProperty("maven", true)
})
defaults(delegateClosureOf<groovy.lang.GroovyObject> {
invokeMethod("publications", arrayOf(
"androidDebug", "androidRelease", "kotlinMultiplatform", "metadata"
))
})
})
}
In the settings.gradle I also added enableFeaturePreview("GRADLE_METADATA").
To implement that gradle I read this article here: https://medium.com/vmware-end-user-computing/publishing-kotlin-multiplatform-artifacts-to-artifactory-maven-a283ae5912d6
Because I want this shared module to be used in other Android App projects I skip all steps regarding the maven publications of the iOS part.
The upload to artifactory is successful with ./gradlew artifactoryPublish:
I try to consume it in the android app and for this I added the connection to artifactory and to this repo in the android app build.gradle file like suggested in artifactory when using "Set Me Up" button. And I also link finally the framework in the dependencies block of the build.gradle of the Android App:
dependencies {
.
.
.
implementation(group: 'com.rb.kmp_test_shared_lib', name: 'shared', version: '1.0.4', ext: 'jar')
}
In the android app I run in this error here:
Could not determine the dependencies of task ':app:lintVitalRelease'.
> Could not resolve all artifacts for configuration ':app:debugCompileClasspath'.
> Could not resolve com.rb.kmp_test_shared_lib:shared:1.0.4.
Required by:
project :app
> No matching variant of com.rb.kmp_test_shared_lib:shared:1.0.4 was found. The consumer was configured to find an API of a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
- Variant 'commonMainMetadataElements-published' capability com.rb.kmp_test_shared_lib:shared:1.0.4:
- Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'
- Other compatible attribute:
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
- Variant 'iosArm64ApiElements-published' capability com.rb.kmp_test_shared_lib:shared:1.0.4:
- Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'
- Other compatible attribute:
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
- Variant 'iosArm64MetadataElements-published' capability com.rb.kmp_test_shared_lib:shared:1.0.4:
- Incompatible because this component declares a usage of 'kotlin-metadata' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'
- Other compatible attribute:
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
- Variant 'iosX64ApiElements-published' capability com.rb.kmp_test_shared_lib:shared:1.0.4:
- Incompatible because this component declares a usage of 'kotlin-api' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'
- Other compatible attribute:
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
- Variant 'iosX64MetadataElements-published' capability com.rb.kmp_test_shared_lib:shared:1.0.4:
- Incompatible because this component declares a usage of 'kotlin-metadata' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'native' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'
- Other compatible attribute:
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
- Variant 'metadataApiElements-published' capability com.rb.kmp_test_shared_lib:shared:1.0.4:
- Incompatible because this component declares a usage of 'kotlin-metadata' of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'common' and the consumer needed an API of a component, as well as attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm'
- Other compatible attribute:
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
Why did I get this error when trying to use that library? How can I exactly consume Kotlin Multiplatform libraries from jfrogs artifactory in other android apps?
It is maybe because of the jars which get uploaded by running ./gradlew artifactoryPublish? There should be aar files uploaded in artifactory?
Maybe this lines here did not work anymore? The article I read to implement that was written in May 2020 and since then there were some major Kotlin Multiplatform releases:
defaults(delegateClosureOf<groovy.lang.GroovyObject> {
invokeMethod("publications", arrayOf(
"androidDebug", "androidRelease", "kotlinMultiplatform", "metadata"
))
})
I guess instead of androidDebug and androidRelease I need to put there some other attributes in.
I am really grateful for every help with this - I am looking for hours for an solution.
For android apps aar libraries are necessary - so I need to upload air files to artifactory.
To upload aar files I add a publishing block to the build.gradle.kts of my shared module in the KMP project:
publishing {
publications {
create<MavenPublication>("aar") {
artifact("$buildDir/outputs/aar/${project.name}-release.aar")
}
}
}
I also changed the artifactory block and replace the defaults part to this:
defaults(delegateClosureOf<groovy.lang.GroovyObject> {
invokeMethod("publications", "aar")
setProperty("publishArtifacts", true)
})
After this changes I clean the project and build all artifacts:
./gradlew clean
./gradlew :shared:build
When all assets build successful (and aar files are in the outputs folder of the KMP project) I upload the aar's successful with ./gradlew artifactoryPublish and then I can simply use them in another android app.
The answer from Vadim of the question Convert to gradle-kotlin-dsl Jfrog.Artifactory config helped me with writing the code to upload aar's to artifactory.