Upgrade from Jetpack Compose 1.0.5 to 1.1.0: Error launching app

Viewed 823

I have just upgraded a fully functional Jetpack compose mobile app from Compose 1.0.5 to 1.1.0. It builds with no errors and no warnings. However, it does not launch anymore.

Problems Tab in Android Studio indicates that are 104 problems related with Choreographer.java ~/Android/Sdk/sources/android-31/android/view

build.gradle (:app)

plugins {
    id 'com.android.application'
    id 'kotlin-android'
    id 'kotlin-kapt'
    id 'dagger.hilt.android.plugin'
}

android {
    compileSdk 31

    defaultConfig {
        applicationId "XXXXXXXXXXXXXXX"
        minSdk 24
        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 '1.1.0'
    }
    packagingOptions {
        resources {
            excludes += '/META-INF/{AL2.0,LGPL2.1}'
        }
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.4.0'
    implementation 'androidx.activity:activity-compose:1.4.0'
    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"

    // Room libraries
    implementation "androidx.room:room-runtime:2.4.1"
    kapt "androidx.room:room-compiler:2.4.1"
    implementation "androidx.room:room-ktx:2.4.1"

    // DataStore Preferences
    implementation "androidx.datastore:datastore-preferences:1.0.0"

    // Hilt dependencies
    implementation "com.google.dagger:hilt-android:$hilt_version"
    kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
    kapt 'androidx.hilt:hilt-compiler:1.0.0'

    // Navigation dependency
    // implementation "androidx.navigation:navigation-compose:2.4.0-alpha10"

    // Accompanist Jetpack Navigation Compose Animation
    implementation "com.google.accompanist:accompanist-navigation-animation:0.19.0"

}

build.gradle (project):

buildscript {
    ext {
        // https://developer.android.com/jetpack/androidx/releases/compose-kotlin
        kotlin_version = '1.6.10'
        compose_version = '1.1.0'
        hilt_version = '2.40.5'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.1.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "com.google.dagger:hilt-android-gradle-plugin:$hilt_version"
    }
}

1 Answers

As mentioned by @PhilipDukhov the problem was in the Accompanist version which for Compose 1.1.0 is 0.23.0. In fact, there are multiple versions of Accompanist for the different versions of Compose, you can find it here.

Important to note that Android Studio does not alert us to newer versions of some libraries (namely, Accompanist), so we must be aware of this fact.

Related