0

So I am struggling to get my app to work after upgrading my project.

I am getting the following error:

> Task :app:compileDebugKotlin FAILED
e: This version (1.0.3) of the Compose Compiler requires Kotlin version 1.5.30 but you appear to be using Kotlin version 1.8.20 which is not known to be compatible.  Please fix your configuration (or `suppressKotlinVersionCompatibilityCheck` but don't say I didn't warn you!).

I have the latest version of the plugin installed (223-1.8.0-release-345-AS8836.35.2231.10406996) on Android Studio Giraffe 2022.3.1, but I cannot get this to go away.

Here is my full build.gradle(:app):

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {

    buildFeatures {
        compose true
    }
    composeOptions {
        kotlinCompilerExtensionVersion '1.0.3'
        kotlinCompilerVersion '1.5.30'
    }

    kotlinOptions {
        jvmTarget = "1.8"
    }

    namespace '__________'
    compileSdk 33

    defaultConfig {
        applicationId "___________"
        minSdk 30
        targetSdkVersion 33
        versionCode 1
        versionName "1.0.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        // Enabling multidex support.
        multiDexEnabled true
        vectorDrawables{
            useSupportLibrary = true
        }
    }

    buildTypes {
        release {
            minifyEnabled true // https://www.youtube.com/watch?v=EOQB8PTLkpY&list=PLWz5rJ2EKKc9Ty3Zl1hvMVUsXfkn93NRk
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }

    kotlinOptions {
        jvmTarget = "17"
    }

// Added for MVVM: https://www.simplifiedcoding.net/firebase-mvvm-example/
    dataBinding {
        enabled = true
    }


}

dependencies {
    implementation 'androidx.activity:activity-compose:1.7.2'
    implementation 'androidx.activity:activity-ktx:1.7.2'
    implementation 'androidx.appcompat:appcompat:1.6.1'
    implementation 'androidx.appcompat:appcompat-resources:1.6.1'
    implementation 'androidx.core:core-ktx:1.10.1'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.multidex:multidex:2.0.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'

    // Lifecycle
    implementation "androidx.lifecycle:lifecycle-runtime-compose:2.6.1"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.1"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.1"
    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.6.1"
    implementation "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.6.1"
    implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.6.1" //https://www.simplifiedcoding.net/firebase-mvvm-example/

    // Compose
    implementation platform('androidx.compose:compose-bom:2023.06.01')
    implementation 'androidx.compose.ui:ui'
    implementation 'androidx.compose.ui:ui-graphics'
    implementation 'androidx.compose.ui:ui-tooling-preview:1.4.3'
    implementation 'androidx.compose.material3:material3:1.1.1'
    implementation "androidx.compose.material:material-icons-extended"
    implementation 'androidx.compose.material:material:1.4.3'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.4'

    debugImplementation 'androidx.compose.ui:ui-tooling:1.4.3'
    debugImplementation 'androidx.compose.ui:ui-test-manifest:1.4.3'

    // Navigation
    implementation 'androidx.navigation:navigation-fragment-ktx:2.6.0'
    implementation 'androidx.navigation:navigation-ui-ktx:2.6.0'

    // Testing
    androidTestImplementation 'androidx.test.ext:junit:1.1.5'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
    testImplementation 'junit:junit:4.13.2'

    // Add the SDKs for any other Firebase products you want to use in your app
    // For example, to use Firebase Authentication and Cloud Firestore
    implementation 'com.google.firebase:firebase-firestore:24.7.0'
    implementation 'com.google.firebase:firebase-auth:22.1.1'
    implementation 'com.google.firebase:firebase-messaging:23.2.1'
    implementation 'com.google.firebase:firebase-core:21.1.1'
    implementation 'com.google.firebase:firebase-storage:20.2.1'
    implementation 'com.google.android.gms:play-services-auth:20.6.0'

    // Add the Firebase SDK for Google Analytics
    implementation 'com.google.firebase:firebase-analytics:21.3.0'

//    // Picasso
//    implementation 'com.squareup.picasso:picasso:2.71828'

    //anko https://www.youtube.com/watch?v=uB7WeED1d1w
//    implementation "org.jetbrains.anko:anko:0.10.4"
//    implementation "org.jetbrains.anko:anko-design:0.10.4"
//    implementation "org.jetbrains.anko:anko-coroutines:0.10.4"

    // Material Dialogs (https://github.com/afollestad/material-dialogs, recommended by CodingWithMitch https://www.youtube.com/watch?v=_sOHZAk6KnA)
    implementation 'com.afollestad.material-dialogs:core:3.3.0'
    implementation 'com.afollestad.material-dialogs:input:3.3.0'
    implementation 'com.afollestad.material-dialogs:datetime:3.3.0'
    implementation 'com.afollestad.material-dialogs:lifecycle:3.3.0'

    // debugImplementation because LeakCanary should only run in debug builds.
    debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.12'

    // Couroutines Dependency
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3'


}

This is my full build.gradle(Project):

// Top-level build file where you can add configuration options common to all sub-projects/modules.


buildscript {


    repositories {
        google()
        mavenCentral()

    }
    dependencies {

        classpath 'com.google.gms:google-services:4.3.15'
        classpath 'androidx.navigation:navigation-safe-args-gradle-plugin:2.6.0'
        classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21'
        classpath 'com.android.tools.build:gradle:8.1.0'

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

allprojects {
    repositories {
        google()
        mavenCentral()
        maven { url 'https://developer.android.com/studio/build/repository' }


    }
}



task clean(type: Delete) {
    delete rootProject.buildDir
}
Scamparelli
  • 756
  • 1
  • 12
  • 28
  • by the way you have two kotlinOptions blocks with two different jvmTarget, in case you don't know, the last block of kotlinOptions will take into effect which will instruct compiler to generate bytecode that is compatible with Java 17 – Vivek Gupta Aug 08 '23 at 19:29
  • Thank you Vivek, noted. This has lead to my next question here in case you can help: https://stackoverflow.com/questions/76868369/buildscript-to-plugins-migration-errors – Scamparelli Aug 09 '23 at 13:45

1 Answers1

1

Following this link you will know that your compiler version should match with the kotlin version. You are using kotlin version 1.8.20 ,in the build file change the compose compiler to 1.4.5

   composeOptions {
    kotlinCompilerExtensionVersion = "1.4.5"
}
Vivek Gupta
  • 747
  • 4
  • 13