I have a problem with setting up an activity that resides in shared code in a KMM project and uses Jetpack Compose. When the activity is in Android source (/app) this works fine. But I'd like to publish a shared (/common) library without any application.
As an example I forked a great minimal KMM+Compose project: https://github.com/cyberhenoch/PeopleInSpace :
- added the compose activity (SharedActivity) to the shared code
- updated the dependencies in shared code androidMain
It compiles fine but at runtime I get:
Process: com.surrus.peopleinspace, PID: 4067 java.lang.NoSuchMethodError: No static method setContent$default(Landroidx/activity/ComponentActivity;Landroidx/compose/runtime/CompositionContext;Lkotlin/jvm/functions/Function0;ILjava/lang/Object;)V in class Landroidx/activity/compose/ComponentActivityKt; or its super classes (declaration of 'androidx.activity.compose.ComponentActivityKt' appears in /data/app/com.surrus.peopleinspace-8P35Dcwzn9_G-xN9YdwFrA==/base.apk) at com.surrus.android.SharedActivity.onCreate(SharedActivity.kt:12)
I tried to add the options described here https://developer.android.com/jetpack/compose/setup#configure_gradle but
- not all can be added to the common module (kotlinOptions?)
- in the original project they are not required and it works perfectly good
- after adding several of them in different combinations it does not even compile (exception: java.lang.NoClassDefFoundError: org/jetbrains/kotlin/serialization/DescriptorSerializerPlugin at java.base/java.lang.ClassLoader.defineClass1(Native Method))
What should I do to make it work? Any help would be appreciated.