Brandon Iceberg
Brandon Iceberg

Reputation: 53

Setting Kotlin version to 1.4.32 creates syntax errors in my Compose project

I am having an issue where my Android Studio project will not build when I go to downgrade it from Kotlin version 1.5.0 -> 1.4.32. When I do this Gradle will sync with no issues but all of my Kotlin code will be red (despite it being correct) and the autocomplete feature no longer works. If I reset my Kotlin version to 1.5.0 the code shows as error free and autocomplete works as intended but the project will still not build due to it not being supported with Compose Compiler. I have tried setting kotlinOptions to ignore this fact but that also gives me build errors. Any help on the matter would be greatly appreciated!

Upvotes: 2

Views: 893

Answers (1)

Joshua
Joshua

Reputation: 3910

This is probably not very recomended, however, it did fix my issue which appears to maybe be the same as yours.

I'm using 1.5.10 for the kotlin standard library in my app/build.gradle and kotlinCompilerVersion is set to 1.4.32:

plugins {
    id 'com.android.application'
    id 'kotlin-android'
}

android {
    compileSdk 30

    . . .

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_11
        targetCompatibility JavaVersion.VERSION_11
    }
    kotlinOptions {
        jvmTarget = '11'
        useIR = true
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion composeVersion
        kotlinCompilerVersion "1.4.32"
    }
}

dependencies {

    implementation "org.jetbrains.kotlin:kotlin-stdlib:1.5.10"

    . . .
}

But in my project's build.gradle I'm using 1.4.32:

buildscript {
    ext {
        composeVersion = "1.0.0-beta07"
        kotlinVersion = "1.4.32"
        accompanistVersion = "0.10.0"
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.0-beta03"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}

. . .

Upvotes: 1

Related Questions