Running tests with createComposeRule and hitting a stack trace like (irrelevant parts omitted):
java.lang.RuntimeException: Could not launch activity
at androidx.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:495)
...
Caused by: java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x14000000 cmp=my.app.package.name.here/android.app.Activity }
...
The OP question is about the use of createComposeRule() which doesn't require a custom activity (it uses ComposeActivity under the hood).
In this case you need to include this below in your gradle file:
debugImplementation("androidx.compose.ui:ui-test-manifest:1.0.0-beta05")
If you take a look at the contents of that package, it's simply an AndroidManifest.xml with an <activity/> entry for androidx.activity.ComponentActivity.
You need to add
<activity android:name="androidx.activity.ComponentActivity" />
to your manifest.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With