Unable to find explicit activity class BootstrapActivity
See original GitHub issueDescription
Making my first attempts at using ActivityScenario, and I immediately stumbled upon this exception
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.me.debug.test/androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2005)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1673)
at androidx.test.runner.MonitoringInstrumentation.execStartActivity(MonitoringInstrumentation.java:508)
at android.app.ContextImpl.startActivity(ContextImpl.java:917)
at android.app.ContextImpl.startActivity(ContextImpl.java:888)
at androidx.test.core.app.InstrumentationActivityInvoker.startActivity(InstrumentationActivityInvoker.java:352)
at androidx.test.core.app.ActivityScenario.launch(ActivityScenario.java:207)
at androidx.test.core.app.ActivityScenario.launch(ActivityScenario.java:184)
at androidx.test.ext.junit.rules.ActivityScenarioRule.lambda$new$0$ActivityScenarioRule(ActivityScenarioRule.java:68)
at androidx.test.ext.junit.rules.ActivityScenarioRule$$Lambda$0.get(Unknown Source:2)
at androidx.test.ext.junit.rules.ActivityScenarioRule.before(ActivityScenarioRule.java:82)
at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at androidx.test.runner.AndroidJUnit4.run(AndroidJUnit4.java:104)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:388)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2145)
Steps to Reproduce
Here’s my code:
import androidx.test.core.app.ActivityScenario
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.runner.AndroidJUnit4
import com.me.MainActivity
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class SampleTest {
private var scenario: ActivityScenario<MainActivity>? = null
@get:Rule
val mainActivityScenarioRule = ActivityScenarioRule<MainActivity>(MainActivity::class.java)
@Before
fun init() {
scenario = mainActivityScenarioRule.scenario
}
@Test
fun basicUseCase() {
}
}
Expected Results
scenario
gets created and I’m able to drive MainActivity’s lifecycle with it
Actual Results
android.content.ActivityNotFoundException
AndroidX Test and Android OS Versions
androidTestImplementation "androidx.test:runner:$androidx_test_runner_version"
androidTestImplementation "androidx.test.espresso:espresso-core:$androidx_test_espresso_version"
androidTestImplementation "androidx.test.espresso:espresso-contrib:$androidx_test_espresso_version"
androidTestImplementation "androidx.test.espresso:espresso-intents:$androidx_test_espresso_version"
androidTestImplementation "androidx.test.uiautomator:uiautomator:$androidx_test_uiautomator_version"
androidTestImplementation "androidx.test.ext:junit:$androidx_test_ext_version"
androidTestImplementation "androidx.test.ext:junit-ktx:$androidx_test_ext_version"
androidTestImplementation "com.google.truth:truth:$google_truth_version"
where
androidx_test_runner_version = '1.1.1'
androidx_test_espresso_version = '3.1.1'
androidx_test_uiautomator_version = '2.2.0'
androidx_test_ext_version = '1.1.0'
Link to a public git repo demonstrating the problem:
Let me know if I should make one, I wonder if I’m just missing something obvious and this isn’t a bug.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11
Top Results From Across the Web
How to get rid of "Unable to find explicit activity class" error ...
ActivityNotFoundException: Unable to find explicit activity class {com.example.textme/java.lang.String}; have you declared this activity in ...
Read more >[Solved] Error: Unable to find explicit activity class in android
In this video, we will see how to solve the error " unable to find explicit activity class " in Android Studio.An issues...
Read more >Android- Resolve Unable to Find Explicit Activity Class Error
While working with Android application project, you may find this error: " Unable to Find Explicit Activity Class Error: "android.content.
Read more >Making Sense of Intent Filters in Android 13 - Medium
Unable to find explicit activity class {component name}; have you declared this activity in your AndroidManifest.xml, or does your intent ...
Read more >Targeting API 33 causes all compose Instrumented Tests to ...
... Unable to find explicit activity class {com.my.myapplication.test/androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity}; have you ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Issue was entirely on my end!
For Android 13 devices, this is fixed in
androidx.test:core:1.5.0-alpha02
, see: https://github.com/android/android-test/issues/1412