Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"RuntimeException: Could not launch activity...Unable to resolve activity for Intent" when running Jetpack Compose UI tests with createComposeRule

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 }
...
like image 493
Ryan M Avatar asked Nov 18 '25 15:11

Ryan M


2 Answers

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.

like image 166
Rodrigo Gomez Avila Avatar answered Nov 21 '25 04:11

Rodrigo Gomez Avila


You need to add

<activity android:name="androidx.activity.ComponentActivity" />

to your manifest.

like image 40
André Ramon Avatar answered Nov 21 '25 04:11

André Ramon



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!