"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.Monito
Solution 1:
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
.
Solution 2:
You need declare an Activity
with name android.app.Activity
in your AndroidManifest.xml
for the Compose UI tests to use to host the content. Add the following within your <application>
tag:
<activityandroid:name="android.app.Activity"android:theme="@style/your_app_theme_here"/>
substituting your_app_theme_here
with a theme that exists in your app.
Solution 3:
You need to add
<activityandroid:name="androidx.activity.ComponentActivity" />
to your manifest.
Post a Comment for ""runtimeexception: Could Not Launch Activity...unable To Resolve Activity For Intent" When Running Jetpack Compose Ui Tests With Createcomposerule"