IllegalStateException: function = <anonymous>, count = 3, index = 3

Viewed 1478

Things were fine till yesterday. Today when I opened system I'm suddenly getting the error:

java.lang.IllegalStateException: function = <anonymous>, count = 3, index = 3

Along with "Internal compiler error", on running my project.

I tried updating my gradle version and gradle plugin version, and also the dependencies I have used, but it didn't work.

How do I solve this?

These are the dependencies I have used:

    def lifecycle_version = "2.3.1"

    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.cardview:cardview:1.0.0'
    implementation "androidx.drawerlayout:drawerlayout:1.1.1"
    implementation "androidx.navigation:navigation-fragment-ktx:2.3.5"
    implementation "androidx.navigation:navigation-ui-ktx:2.3.5"
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
    implementation 'com.shawnlin:number-picker:2.4.11'
    implementation 'com.karumi:dexter:6.2.1'
    implementation 'com.github.IslamKhSh:CardSlider:1.0.1'
    implementation 'com.intuit.sdp:sdp-android:1.0.6'
    implementation 'com.intuit.ssp:ssp-android:1.0.6'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
    implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
    implementation 'com.google.android.gms:play-services-auth:19.0.0'
    implementation 'com.google.android.gms:play-services-auth-api-phone:17.5.0'
    implementation 'net.yslibrary.keyboardvisibilityevent:keyboardvisibilityevent:3.0.0-RC2'
    // Lottie dependency
    implementation "com.airbnb.android:lottie:3.7.0"

    //Autostart settings open
    implementation 'com.thelittlefireman:AppKillerManager:2.1.1'

    // Retrofit
    implementation 'com.squareup.retrofit2:retrofit:2.3.0'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0'

    // JSON Parsing
    implementation 'com.google.code.gson:gson:2.8.6'
    implementation 'com.squareup.retrofit2:converter-gson:2.1.0'

    implementation 'com.android.support:multidex:1.0.3'

    implementation 'androidx.cardview:cardview:1.0.0'

    // ViewModel
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
    // LiveData
    implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"

    implementation "androidx.core:core-ktx:1.3.2"
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.31"

    implementation "org.koin:koin-core:2.2.2"
    implementation "org.koin:koin-androidx-viewmodel:2.2.2"
    implementation "androidx.datastore:datastore-preferences:1.0.0-beta01"
    implementation 'com.github.pwittchen:swipe-rx2:0.3.0'
    implementation "androidx.compose.material:material:1.0.0-beta06"
    implementation "androidx.compose.ui:ui-tooling:1.0.0-beta06"
    implementation "androidx.compose.ui:ui:1.0.0-beta07"
    implementation "androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha06"
    implementation "androidx.navigation:navigation-compose:1.0.0-alpha10"
    implementation "androidx.activity:activity-compose:1.3.0-alpha08"
    implementation "androidx.compose.animation:animation:1.0.0-beta06"
    implementation "androidx.compose.animation:animation-core:1.0.0-beta07"
    implementation "androidx.ui:ui-framework:0.1.0-dev03"
    implementation "androidx.compose.runtime:runtime-livedata:1.0.0-beta06"
    implementation group: 'com.airbnb.android', name: 'lottie-compose', version: '1.0.0-beta03-1'

    testImplementation 'junit:junit:4.13.1'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
12 Answers

Worked for me if I downgrade all implementations for compose to beta6 and compose navigation to 1.0.0-alpha08. Or you should update kotlinCompilerExtensionVersion to 1.0.0-beta7 in composeOptions(in build.gradle, app Module) like this:

android {
    ...
    composeOptions {
         val composeVersion by extra("1.0.0-beta07")
         kotlinCompilerExtensionVersion = composeVersion
    }
    ...
}

This sample was in build.gradle.kts

In my case downgrading ConstraintLayout version from 1.0.0-alpha07 to 1.0.0-alpha06 helped.

implementation "androidx.constraintlayout:constraintlayout-compose:1.0.0-alpha06"

I was able to fix this by upgrading all compose dependencies to beta07 along with the kotlinCompilerExtensionVersion to 1.0.0-beta07.

I'm using accompanist library as well which required an upgrade to version "0.10.0" which is built to work with compose beta07.

For me this happened right after I updated androidx.navigation:navigation-compose from 1.0 to 2.4

I ran into this myself. The two problem dependencies were:

  • androidx.compose.ui:ui:1.0.0-beta07
  • androidx.activity:activity-compose:1.3.0-alpha08

I rolled each back one release and I'm building again:

  • androidx.compose.ui:ui:1.0.0-beta06
  • androidx.activity:activity-compose:1.3.0-alpha07

Try to downgrade 'activity-compose' from '1.3.0-alpha08' to '1.3.0-alpha07'

implementation "androidx.activity:activity-compose:1.3.0-alpha07"

This issue occurred when I updated Coil version for image loading to 0.11.0.

For me the solution was to upgrade all compose dependencies to the latest version(in my case 1.0.0-beta08) and for that also the kotlinCompilerExtensionVersion had to be updated to the latest version as well (in my case '1.5.10')

For me the problem was the accompanist-coil I updated it to 0.10.0 today and because of this error, I downgraded the version to 0.6.2

Error appears when i update androidx.constraintlayout:constraintlayout-compose to 1.0.0-alpha07 (from 1.0.0-alpha06) and disappears when i updated all my dependencies to recent versions: all androidx.compose.* to 1.0.0-beta07, androidx.activity:activity-compose to 1.3.0-alpha08 and androidx.constraintlayout:constraintlayout-compose to 1.0.0-alpha07

Compose Beta 07 introduced breaking changes so to fix this issue I had to update Compose to 1.0.0-beta07 and every other -compose library to the latest possible version:

activity-compose:1.3.0-alpha08
navigation-compose:2.4.0-alpha01
hilt-navigation-compose:1.0.0-alpha02
etc...

What worked for me was changing the kotlinCompilerExtensionVersion to version "1.0.0-beta07" in the app build.gradle file.

compose_version "1.0.0-beta07" will need the kotlinCompilerVersion upto "1.4.32". My compose_version is "1.0.0-beta01", so I choose to downgrade the constraintlayout-compose from "1.0.0-alpha07" to "1.0.0-alpha06"

Related