Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.NoSuchMethodError: No virtual method setContent(Lkotlin/jvm/functions/Function0;)V

Trying to migrate Android native view to Jetpack compose.

Added dependencies per Jetpack-compose-migration#3 in build.gradle

I'm still getting below exception.

java.lang.NoSuchMethodError: No virtual method setContent(Lkotlin/jvm/functions/Function0;)V in class Landroidx/compose/ui/platform/ComposeView;

Any help on this?

Trying to solve this exception.

like image 352
Karthik P Avatar asked Dec 10 '25 08:12

Karthik P


1 Answers

Jetpack Compose doesn't use Activity class to your activities, it uses ComponentActivity.

You can add this implementation to use:

implementation 'androidx.activity:activity-compose'

And in your activity that contains the setContent function:

Replace class MainActivity: Activity() for class MainActivity: ComponentActivity()

like image 199
Otávio Moreira Avatar answered Dec 11 '25 23:12

Otávio Moreira



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!