skip to Main Content

I just run RC1 version of artic fox, unfortunately I’m always getting the same error when I try to run empty compose activity project and that’s the error.

I have no idea where 1.0.0-rc01 come from, when everything is changed to rc02

> Task :app:compileDebugKotlin FAILED
w: ATTENTION!
This build uses unsafe internal compiler arguments:

-XXLanguage:+NonParenthesizedAnnotationsOnFunctionalTypes

This mode is not recommended for production use,
as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!

e: This version (1.0.0-rc01) of the Compose Compiler requires Kotlin version 1.5.10 but you appear to be using Kotlin version 1.5.21 which is not known to be compatible.  Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).

Execution failed for task :app:compileDebugKotlin

It’s a fresh copy of RC1 Arctic Fox, just did a few updates. What am I missing here?

Here is my build.gradle

buildscript {
    ext {
        compose_version = '1.0.0-rc02'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath "com.android.tools.build:gradle:7.0.0-rc01"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

:app

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

android {
    compileSdk 31
    buildToolsVersion "31.0.0"

    defaultConfig {
        applicationId "com.example.testoandroid1"
        minSdk 21
        targetSdk 31
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables {
            useSupportLibrary true
        }
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
        useIR = true
    }
    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion compose_version

    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.6.0'
    implementation 'androidx.appcompat:appcompat:1.3.1'
    implementation 'com.google.android.material:material:1.4.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    // Material design icons
    implementation 'androidx.compose.material:material-icons-core:1.0.0-rc02'
    implementation 'androidx.compose.material:material-icons-extended:1.0.0-rc02'
    implementation "androidx.compose.material:material:$compose_version"
    // Tooling support (Previews, etc.)
    implementation 'androidx.compose.ui:ui-tooling:1.0.0-rc02'
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    // Foundation (Border, Background, Box, Image, Scroll, shapes, animations, etc.)
    implementation 'androidx.compose.foundation:foundation:1.0.0-rc02'
    // Integration with ViewModels
    implementation 'androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha07'
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
    implementation 'androidx.activity:activity-compose:1.3.0-rc02'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
    // Integration with observables
    implementation 'androidx.compose.runtime:runtime-livedata:1.0.0-rc02'
    implementation 'androidx.compose.runtime:runtime-rxjava2:1.0.0-rc02'
}

4

Answers


  1. You had to use 1.5.10 kotlin with compose, it’s the latest version supported right now

    I haven’t found specific restrictions in the docs, but on the release page(https://developer.android.com/jetpack/androidx/releases/compose-compiler#declaring_dependencies) they suggest using 1.5.10.

    If you try to build the app using 1.5.21, you’ll get an error:

    e: This version (1.0.0-rc02) of the Compose Compiler requires Kotlin version 1.5.10 but you appear to be using Kotlin version 1.5.21 which is not known to be compatible.  Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).
    

    I’ve tried building it with suppressKotlinVersionCompatibilityCheck, in my case it fails with java.lang.InstantiationError: org.jetbrains.kotlin.ir.util.TypeTranslator.

    I suggest it’s has something to do with new kotlin backend which gets many updates in recent versions, and looks like compose depends on it much.

    Login or Signup to reply.
  2. Change the second dependency in your project level build.gradle file to

    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"

    Login or Signup to reply.
  3. Change your Kotlin version of the project to 1.5.21 to 1.5.10. Because Jetpack compose 1.0.0-rc1 or rc2 version only works with Kotlin Version 1.5.10.

    Previously:

    1.5.21

        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21"
    

    Make it now:

    1.5.10

        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
    
    Login or Signup to reply.
  4. Compose supports Kotlin 1.5.21 starting from 1.0.1.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search