Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find explicit activity class BootstrapActivity #196

Closed
sophiataskova opened this issue Jan 28, 2019 · 14 comments
Closed

Unable to find explicit activity class BootstrapActivity #196

sophiataskova opened this issue Jan 28, 2019 · 14 comments

Comments

@sophiataskova
Copy link

sophiataskova commented Jan 28, 2019

Description

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.

@sophiataskova
Copy link
Author

Issue was entirely on my end!

@michaelbukachi
Copy link

@sophiataskova how did you solve your issue? Facing the same issue.

@copolii
Copy link

copolii commented Jul 5, 2019

@sophiataskova it would be really nice if you had left a little more detail as to what you did wrong and what you did to fix it on your end.

@subprogram
Copy link

Uninstalling of the test package is helped in my case.

@leonardosibela
Copy link

@sophiataskova how did you solve your issue? Facing the same issue.

@MattWilliams89
Copy link

Can anyone please share how they resolved this?

@MattWilliams89
Copy link

Adding

<activity
   android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
   android:label="InstrumentationActivityInvoker$BootstrapActivity" />

to the AndroidManifest of the androidTest sourceSet seems to work, but this feels like a workaround.

@lassana
Copy link

lassana commented Jan 6, 2022

I've started seeing this but only on Android 4.4. InstrumentationActivityInvoker$BootstrapActivity class is obviously in the DEX file. What can cause this?

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.Example.test/androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity}: java.lang.ClassNotFoundException: Didn't find class "androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.example.Example.test-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.Example.test-2, /vendor/lib, /system/lib]]

@Keremturker
Copy link

Adding

<activity
   android:name="androidx.test.core.app.InstrumentationActivityInvoker$BootstrapActivity"
   android:label="InstrumentationActivityInvoker$BootstrapActivity" />

to the AndroidManifest of the androidTest sourceSet seems to work, but this feels like a workaround.

it works for me. Thank you :)

@elevenfive
Copy link

For Android 13 devices, this is fixed in androidx.test:core:1.5.0-alpha02, see: #1412

michaelng0107 added a commit to uoftblueprint/the-period-purse-android that referenced this issue Nov 29, 2022
Was seeing the following issues when I run tests in NavigationTest:
- android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.theperiodpurse.test/androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared <intent-filter>?
- android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.theperiodpurse.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>?

Referred to android/android-test#196 for the fix.
Looks like this is fixed in androidx.test:core:1.5.0-alpha02.
leowrites pushed a commit to uoftblueprint/the-period-purse-android that referenced this issue Dec 5, 2022
* Added Basic Calendar Cycle Top Bar

* added dependencies

* Styled Calendar Cycle Top Bar

* Changed TopBar to use tabs, added navigation

* setup basic navigation bar and graph

* added calender navgiation to FAB

* modularized BottomNav

* modularized FAB

* moved Screen enum to NavigationGraph

* Added Swiping to tabs, comments

* cleanup

* removed unused icon

* Updated Indicator Color

* removed unused colors

* added dependencies and tests

* Added activity to manifest - temp fix so tests run

Was seeing the following issues when I run tests in NavigationTest:
- android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.theperiodpurse.test/androidx.test.core.app.InstrumentationActivityInvoker$EmptyActivity}; have you declared this activity in your AndroidManifest.xml, or does your intent not match its declared <intent-filter>?
- android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.theperiodpurse.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>?

Referred to android/android-test#196 for the fix.
Looks like this is fixed in androidx.test:core:1.5.0-alpha02.

* removed changes to manifest

* added androidTestResultsUserPreferences to gitignore

* added useful contentDescription to FAB

* added instrumental tests to CI

* added emulator use to workflow

* fixed typo in ci

* test with macOS

* specify system image

* Added content description for testing

* Added content description for testing

* Added testing for tabs

* added check to hide navigation bar during onboarding

* better implementation for hiding nav bar

* bandaid fix for tests

* fix tests

* create different screen to start in Calendar page

* added skipOnboarding option to AppScreen

* popback stack after onboarding

* #3 Created the Calendar Layout (#33)

* Added basic calendar setup to the screen

* Changed the minSDK in Project Configs

* Updated Visuals to look like original app

* Added Click Functionality

* Revert "#3 Created the Calendar Layout (#33)" (#38)

This reverts commit 18909c4.

Co-authored-by: Pierre-William Lessard <lessardpw@gmail.com>
Co-authored-by: Madeline <93456777+madelahn@users.noreply.github.com>
@VuNgN
Copy link

VuNgN commented Dec 14, 2022

For Android 13 devices, this is fixed in androidx.test:core:1.5.0-alpha02, see: #1412

It works for me. Thank you 😄

@krischik
Copy link

krischik commented Jan 23, 2023

Issue was entirely on my end!

That happens sometimes. But how did you solve it? This is the top search result for the problem. Many people are interested to know how you solved the problem.

Anyway the solution is described in #1412 .

@Wavey1287
Copy link

@sophiataskova
Share the solution if you're going to make a post like this. Super selfish to just leave it hanging. Thanks to all the others in this thread that actually contributed. Updating the Testing Dependency in the build.gradle for the module:app to

androidTestImplementation "androidx.test:core-ktx:1.5.0"

worked for me. Was on 1.4.0 before when getting this error. Thanks @VuNgN

@DonMykl
Copy link

DonMykl commented Aug 31, 2023

For Android 13 devices, this is fixed in androidx.test:core:1.5.0-alpha02, see: #1412

Thanks for this, saving for later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests