Ive got a error like this while building my project:
e: This version (1.1.1) of the Compose Compiler requires Kotlin version 1.6.10 but you appear to be using Kotlin version 1.6.20 which is not known to be compatible. Please fix your configuration (or suppressKotlinVersionCompatibilityCheck but don't say I didn't warn you!).
I'm using the newest IntellIJ Pro, and the newest kotlin
How i can make the compose compile with the project?
for kotlin version 1.6.20 you need to add this line in your build.gradle
composeOptions {
kotlinCompilerExtensionVersion '1.2.0-alpha08'
}
Refer to this documentation by google to find out more about kotlin compatibility to different compose versions
You need to use kotlin version 1.6.10 to compile project with this version of compose. In next releases may be thay add new version of kotlin support.
Change your gradle/maven properties to solve this problem.
In Gradle change:
kotlin("jvm") version "1.6.20"
to:
kotlin("jvm") version "1.6.10"
Or you can add compiler args (But there may be problems):
"-P", "plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true"
Here you can see compose and kotlin version mapping
https://developer.android.com/jetpack/androidx/releases/compose-kotlin
1.2.0-alpha08 ->1.6.20
1.1.0-rc02 -1.2.0-alpha07 ->1.6.10
Following the compatibility table posted by user2851150 above,https://developer.android.com/jetpack/androidx/releases/compose-kotlin, it works for me setting in build.gradle (module) :
android{
...
composeOptions {
kotlinCompilerExtensionVersion '1.1.1'
kotlinCompilerVersion '1.6.10'
}
...
}
You need to follow 2 steps for this,
go to your build.gradle(project) and there change your kotlin version for kotlin-gradle-plugin
ext.kotlin_version = '1.6.10'
//....
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
change your kotlin version for plugins -
plugins {
...
...
id 'org.jetbrains.kotlin.android' version '1.6.10' apply false
}
Another update to this answer, since they still have not fixed this for Chipmunk. I left in comments what was causing the issue, so you may have to update again with new versions.
buildscript {
ext {
//compose_version = '1.1.0-beta01' -> causes problems
compose_version = '1.2.0-alpha08'
}
}// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
//id 'org.jetbrains.kotlin.android' version '1.5.31' apply false -> causes problems
id 'org.jetbrains.kotlin.android' version '1.6.20' apply false
}
Go to the build.gradle in project level and change the kotlin version to mapped the required and compatible version
Related
I've created a KMM project, and also an Xcode project with a build phase that calls ./gradlew embedAndSignAppleFrameworkForXcode. It runs successfully, but generates a .framework, not an .xcframework; and we really need the latter for modern Xcode.
Am i missing something? I read that modern versions of kotlin can generate the xcframework directly, but i'm not sure how. Is there a gradle task for this?
Thanks so much :)
According to Kdoctor, I have:
Xcode 14.1
Android studio 2021.3
Kotlin Plugin: 213-1.7.20
Kotlin MM plugin: 0.5.1(213)-60
You should declare your XCFrameworks, then it'll register three tasks for you.
assembleXCFramework, assembleDebugXCFramework, and assembleReleaseXCFramework.
Here is an example of build.gradle:
import org.jetbrains.kotlin.gradle.plugin.mpp.apple.XCFramework
plugins {
kotlin("multiplatform")
}
kotlin {
val xcf = XCFramework()
val iosTargets = listOf(iosX64(), iosArm64(), iosSimulatorArm64())
iosTargets.forEach {
it.binaries.framework {
baseName = "shared"
xcf.add(this)
}
}
}
For more information, visit kotlin docs.
I have a live react native app, which was working fine. But now I need to made some changes to it but I am unable to do so after new updates and new gradle version. I have tried on multiple PCs and workspaces but all are of no use same error on every system pops up. giving some errors which are as under and attached screenshot.
FAILURE: Build failed with an exception.
The Kotlin Gradle plugin was loaded multiple times in different subprojects, which is not supported and may break the build.
This might happen in subprojects that apply the Kotlin plugins with the Gradle 'plugins { ... }' DSL if they specify explicit versions, even if the versions are equal.
Please add the Kotlin plugin to the common parent project or the root project, then remove the versions in the subprojects.
If the parent project does not need the plugin, add 'apply false' to the plugin line.
See: https://docs.gradle.org/current/userguide/plugins.html#sec:subprojects_plugins_dsl
The Kotlin plugin was loaded in the following projects: ':react-native-alarm-clock', ':react-native-webview'
What went wrong:
Execution failed for task ':invertase_react-native-apple-authentication:compileDebugKotlin'.
Screenshot of the error
another Screenshot of the error
I have a live react native app, which was working fine. But now I need to made some changes to it but I am unable to do so. I have tried on multiple PCs and workspaces but all are of no use same error on every system pops up.
add kotlin version in you android/build.gradle
buildscript {
ext {
...
kotlin_version='1.6.0' //add This change version with your installed kotlin version
...
}
repositories {
google()
mavenCentral()
}
dependencies {
...
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" //add This
...
}
}
Just go to build.gradle(Project:yourProjectName)
change
Plugin {
...
id 'org.jetbrains.kotlin.android' version '1.4.x' apply false
...
}
To
Plugin {
...
id 'org.jetbrains.kotlin.android' version '1.6.0' apply false
...
}
I'm a beginner with gradle and would like to use koin in my Kotlin project.
However, I get the following error
Execution failed for task ':compileTestKotlin'.
> Error while evaluating property 'filteredArgumentsMap' of task ':compileTestKotlin'
> Could not resolve all files for configuration ':testCompileClasspath'.
> Could not resolve org.jetbrains.kotlin:kotlin-test-junit5:1.6.20.
Required by:
project : > org.jetbrains.kotlin:kotlin-test:1.6.20
> Module 'org.jetbrains.kotlin:kotlin-test-junit5' has been rejected:
Cannot select module with conflict on capability 'org.jetbrains.kotlin:kotlin-test-framework-impl:1.6.20' also provided by [org.jetbrains.kotlin:kotlin-test-junit:1.6.10(junitApi)]
> Could not resolve org.jetbrains.kotlin:kotlin-test-junit:1.6.10.
Required by:
project : > io.insert-koin:koin-test:3.2.0-beta-1 > io.insert-koin:koin-test-jvm:3.2.0-beta-1
> Module 'org.jetbrains.kotlin:kotlin-test-junit' has been rejected:
Cannot select module with conflict on capability 'org.jetbrains.kotlin:kotlin-test-framework-impl:1.6.10' also provided by [org.jetbrains.kotlin:kotlin-test-junit5:1.6.20(junit5Api)]```
This is my gradle.build.kts file
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
val koinVersion = "3.2.0-beta-1"
plugins {
kotlin("jvm") version "1.6.20"
kotlin("plugin.serialization") version "1.6.10"
application
}
group = "org.example"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
implementation("io.insert-koin:koin-core:$koinVersion")
testImplementation("io.insert-koin:koin-test:$koinVersion")
testImplementation("io.insert-koin:koin-test-junit5:$koinVersion")
testImplementation("com.willowtreeapps.assertk:assertk-jvm:0.25")
testImplementation(kotlin("test"))
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
application {
mainClass.set("MainKt")
}
It looks like there are 3 problems
As I mentioned in the comment, the Kotlin JVM and Serialization plugins have mismatched versions. These should always be the same!
plugins {
kotlin("jvm") version "1.6.21"
kotlin("plugin.serialization") version "1.6.21"
application
}
However, as you discovered, it still doesn't work. There's a larger error message, with three errors.
Could not resolve io.insert-koin:koin-test-junit5:3.2.0-beta-1
Could not resolve org.jetbrains.kotlin:kotlin-test-junit5:1.6.21
Could not resolve org.jetbrains.kotlin:kotlin-test-junit:1.6.10
Let's go through them one-by-one
Java 11 library, Java 8 project
Here's the reason that Gradle gives for the first failure:
Could not resolve io.insert-koin:koin-test-junit5:3.2.0-beta-1.
No matching variant of io.insert-koin:koin-test-junit5:3.2.0-beta-1 was found. The consumer was configured to find an API of a library compatible with Java 8, 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
Incompatible because this component declares a component compatible with Java 11 and the consumer needed a component compatible with Java 8
The component, koin-test-junit5, is only compatible with Java 11, but your project needs Java 8 (kotlinOptions.jvmTarget = "1.8").
Let's fix this first, using Gradle Toolchain
tasks.withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "11"
}
kotlin {
jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(11))
}
}
That resolves the Java version mis-match, and leaves two more errors.
conflict on capability - incompatible libraries
Cannot select module with conflict on capability
Cannot select module with conflict on capability 'org.jetbrains.kotlin:kotlin-test-framework-impl:1.6.10' also provided by [org.jetbrains.kotlin:kotlin-test-junit:1.6.10(junitApi)]
Cannot select module with conflict on capability 'org.jetbrains.kotlin:kotlin-test-framework-impl:1.6.10' also provided by [org.jetbrains.kotlin:kotlin-test-junit5:1.6.10(junit5Api)]
Understanding this one requires quite a bit of knowledge of how Gradle selects versions.
tl;dr: org.jetbrains.kotlin:kotlin-test-junit and org.jetbrains.kotlin:kotlin-test-junit5 are incompatible. You can only use one or the other - not both
I don't really understand what Koin needs to work best. It looks like it has a hard dependency on JUnit5, so you'd have to use these dependencies, and wouldn't be able to use kotlin("test")
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.2")
implementation("io.insert-koin:koin-core:$koinVersion")
testImplementation("io.insert-koin:koin-test:$koinVersion")
testImplementation("io.insert-koin:koin-test-junit5:$koinVersion")
testImplementation("com.willowtreeapps.assertk:assertk:0.25")
testImplementation("org.junit.jupiter:junit-jupiter:5.8.2")
// incompatible with JUnit 5, which I think is required by Koin?
// testImplementation(kotlin("test"))
}
Explanation
In short, when you use Gradle to build a library, you can declare 'attributes'. They're free-form strings, so they can really be anything. They describe things like "this library needs Java 11" or "this is test coverage data".
Some attributes are important to Gradle resolving a project's dependencies. The error you originally got was caused by one such attribute: 'capability'. It describes the Maven coordinates that the library produces.
In the case of the Maven coordinates, if they clash, then Gradle doesn't know what to do, and throws an error. It's up to the user to fix it. There's a lot of Gradle docs about conflict resolution, but usually the simplest answer is to is remove any conflicting dependencies.
What's interesting about capabilities is that because it's just a string, you can add anything to it. And what the authors of org.jetbrains.kotlin:kotlin-test-junit5 and org.jetbrains.kotlin:kotlin-test-junit have done is given them both the same capability.
org.jetbrains.kotlin:kotlin-test-framework-impl:1.6.10
If you search for this library you'll find it doesn't exist. That's because the capability is completely artificial! The authors have made it up, specifically so Gradle will throw an error, and it's up to the user to fix it.
So that's the fix: choose either kotlin-test-junit or kotlin-test-junit5, because you can't have both.
I think org.jetbrains.kotlin:kotlin-test-junit5 has problem with dependencies.
I also struggled with the same issue, so I tried multiple solutions but it all fails.
And I realized that, when just add dependency for kotlin-test-junit5, the kotlin-test-junit is also added to the external libraries.
So here's the working solution for me.
I added this line to gradle first to enable useJunitPlatform()
tasks.withType<Test> {
useJUnitPlatform()
}
after that, i exclude kotlin-test-junit from every references like this,
testImplementation("io.ktor:ktor-server-tests-jvm:$ktorVersion")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5:$kotlinVersion") {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-test-junit")
}
// Dependency Injection
val koinVersion: String by project
implementation("io.insert-koin", "koin-ktor", koinVersion)
implementation("io.insert-koin", "koin-logger-slf4j", koinVersion)
testImplementation("io.insert-koin", "koin-test-junit5", koinVersion) {
exclude(group = "org.jetbrains.kotlin", module = "kotlin-test-junit")
}
After that, junit5 test was working perfectly.
In, quite literally a hello world project the IDE seems to think println and any other parts of kotlin.io are not resolved.
The project builds and runs just fine, however. The issue exists in 1.4.0 but not 1.3.72.
The io package in kotlin-stdlib-1.4.10.jar the IDE seems to think is missing, even though it really isn't (ss attached)
The following is my build.gradle. Changing 1.4.10 to 1.3.72 fixes all the problems.
plugins {
kotlin("jvm") version "1.4.10"
}
group = "ga.rubydesic"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
}
tasks {
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
}
Had a similar-sounding issue and wanted to add what happened / solved it:
Our code was using 1.4.20, but a gradle dependency was causing us to also include 1.4.30. Gradle didn't care, but it caused IntelliJ to stop resolving kotlin.io. Weirdly, existing IntelliJ projects continued to work, but fresh checkouts were seeing the problem.
Once we upgraded to 1.4.30, IntelliJ was fine again. Seemingly, multiple 1.4.x versions caused this problem.
I have noted the same issue in IntelliJ 2020.2, Kotlin 1.4.10 and gradle. Switching back to 1.3.72 works fine. Funny thing is it compiles ok, just red markers for things like println and listOf and no code completion.
I'm working with IntelliJ 15.0.6, SpringBoot 1.4.3.RELEASE, Gradle 2.14 and Groovy 2.3.11.
I get the following message from IntelliJ:
I tried following from StackOverFlow, the official documentation and JavaCodeGeeks with no success.
This is my configuration file:
#Configuration
#ConfigurationProperties(prefix = "configuracoes")
class GeralConfiguration {
def proxyEndereco
def proxyPorta
}
And the relevant part of my application.yaml file:
configuracoes:
proxyEndereco: http://fake.com
proxyPorta: 8080
If I remove #ConfigurationProperties from my configuration file, the message disappears.
This is my build.gradle file:
buildscript {
repositories {
mavenLocal()
maven {url('http://repo.spring.io/plugins-release')}
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.3.RELEASE")
classpath('org.springframework.build.gradle:propdeps-plugin:0.0.7')
}
}
apply plugin: 'groovy'
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'propdeps'
apply plugin: 'propdeps-idea'
sourceCompatibility = 1.7
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile("org.springframework.boot:spring-boot-starter")
compile("org.springframework.boot:spring-boot-devtools")
optional("org.springframework.boot:spring-boot-configuration-processor")
compile('org.codehaus.groovy:groovy-all:2.3.11')
compile('com.machinepublishers:jbrowserdriver:0.17.3')
compile("org.im4java:im4java:1.4.0")
testCompile("org.springframework.boot:spring-boot-starter-test")
testCompile("org.spockframework:spock-core:1.1-groovy-2.4-rc-3")
}
compileJava.dependsOn(processResources)
compileGroovy.dependsOn(processResources)
Any ideas on what is going on and how I can fix this?
Unfortunately, the annotation processor is not supported with Groovy. You may want to report that IJ shouldn't show this warning with Groovy code.
#Stephane helped me find the answer.
Indeed annotation processor is not supported with Groovy but I didn't manage to get it to work inside src/main/java as well.
I found out that the classes subfolder inside build was marked as excluded by IntelliJ (I don't know why).
As I tried fixing issues one by one I was never getting success. When I performed all fixes at once and marked the classes subfolder as NOT excluded everything worked fine (although IntelliJ keeps showing me the error message).
Thanks to #Stephane for helping me.