android-testify
android-testify copied to clipboard
[ComposableScreenshotRule] API 33 -- android.content.ActivityNotFoundException: Unable to find explicit activity class
Describe the bug
As of API 33, you can no longer run screenshot test that use ComposableTestActivity. It seems that Google changed what is allowable in the manifest entries for Activities. The ComposableTestActivity is defined as part of the androidTest configuration, and so is not visible in the debug build flavor of the app. We need a solution that will make that Activity visible to the app.
This issue relates to:
- [ ] The Kotlin library
- [x] Compose Extension Library
- [ ] The Gradle plugin
- [ ] The IntelliJ Platform plugin
- [ ] The sample code
- [ ] The documentation
To Reproduce
- Configure an emulator using API 33
- Run the sample tests (
./gradlew sample:screenshotTest)
Results:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.servicetitan.work.debug.test/androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared <intent-filter>?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2158)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1805)
at androidx.test.runner.MonitoringInstrumentation.execStartActivity(MonitoringInstrumentation.java:603)
at android.app.ContextImpl.startActivity(ContextImpl.java:1101)
at android.content.ContextWrapper.startActivity(ContextWrapper.java:454)
at androidx.test.core.app.InstrumentationActivityInvoker.startActivity(InstrumentationActivityInvoker.java:431)
at androidx.test.core.app.InstrumentationActivityInvoker.startActivity(InstrumentationActivityInvoker.java:437)
at androidx.test.core.app.ActivityScenario.launchInternal(ActivityScenario.java:265)
at androidx.test.core.app.ActivityScenario.launch(ActivityScenario.java:195)
at androidx.test.ext.junit.rules.ActivityScenarioRule.lambda$new$0$ActivityScenarioRule(ActivityScenarioRule.java:70)
at androidx.test.ext.junit.rules.ActivityScenarioRule$$Lambda$0.get(ActivityScenarioRule.java:70)
at androidx.test.ext.junit.rules.ActivityScenarioRule.before(ActivityScenarioRule.java:103)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:50)
Expected behavior
Tests should run as expected.
Desktop (please complete the following information):
- OS: macOS
- Version 12.2.1
Target Android Device (please complete the following information):
- Device: Any
- Physical or Virtual: Any
- API Level: 33 (error does not occur on 32 or earlier)
- Testify Key:
33-1080x2280@440dp-en_US