Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoSuchMethodError startRestartGroup after upgrading Jetpack Compose to 1.0.0‑beta07

I just updated the compose version to 1.0.0‑beta07, and its showing this run time error

No interface method startRestartGroup(ILjava/lang/String;)Landroidx/compose/runtime/Composer; in class Landroidx/compose/runtime/Composer; or its super classes (declaration of 'androidx.compose.runtime.Composer' 
....
 at com.google.accompanist.coil.CoilImage__CoilKt.CoilImage(Coil.kt:245)
        at com.google.accompanist.coil.CoilImage.CoilImage(Coil.kt:1)

below is my gradle dependencies file

implementation 'androidx.core:core-ktx:1.5.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.3.0'

    implementation "androidx.compose.compiler:compiler:$compose_version"
    implementation "androidx.compose.ui:ui:$compose_version"
    implementation "androidx.compose.material:material:$compose_version"
    implementation "androidx.compose.ui:ui-tooling:$compose_version"
    implementation "androidx.compose.runtime:runtime:$compose_version"
    implementation "androidx.compose.runtime:runtime-livedata:$compose_version"

    implementation 'androidx.activity:activity-compose:1.3.0-alpha08'
    implementation "androidx.lifecycle:lifecycle-viewmodel-compose:1.0.0-alpha05"
    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'

    implementation "io.coil-kt:coil-gif:1.2.1"
    implementation "io.coil-kt:coil-svg:1.2.1"
    implementation "com.google.accompanist:accompanist-coil:0.6.2"

and version compose_version = '1.0.0-beta07'

like image 334
Bharat Kumar Avatar asked May 24 '21 05:05

Bharat Kumar


2 Answers

Every library needs to be recompiled against beta07 to work, as per the Compose release notes:

Note: Libraries dependent on Compose will need to recompile with version 1.0.0‑beta07. Otherwise, libraries may encounter a NoSuchMethodError, such as: java.lang.NoSuchMethodError: No interface method startReplaceableGroup(ILjava/lang/String;)V in class Landroidx/compose/runtime/Composer; or its super classes. (Ia34e6)

In your case you have to update the accompanist libraries with the 0.10.0.

Change:

implementation "com.google.accompanist:accompanist-coil:0.6.2"

to

implementation "com.google.accompanist:accompanist-coil:0.10.0"
like image 72
Gabriele Mariotti Avatar answered Sep 29 '22 19:09

Gabriele Mariotti


Coil, Glide and Image Loading Core have been removed After being deprecated in v0.14.0, it's time to remove the coil, glide and imageloading-core libraries. Some discussion about this can be seen on the Kotlin Slack: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1627482619344000. the recommendation is to move to https://coil-kt.github.io/coil/compose/

So Change ;

implementation "com.google.accompanist:accompanist-coil:0.6.2"

to

implementation("io.coil-kt:coil-compose:1.3.2")

Also; CoilImage removed too, you can use;

Image(
    painter = rememberImagePainter("https://www.example.com/image.jpg"),
    contentDescription = null,
    modifier = Modifier.size(128.dp)
)
like image 38
Ofs Avatar answered Sep 29 '22 18:09

Ofs