I\'m trying to use the new FragmentScenario APIs of the androidx testing libraries for local testing and instrumentation testing(androidTest). The api works fine in local enviro
You need to add "fragment-testing" dependency to the APK under testing instead of test APK.
So please update your build.gradle to
debugImplementation "androidx.fragment:fragment-testing:$fragment_version"
from
androidTestImplementation "androidx.fragment:fragment-testing:$fragment_version"
(This is due to implementation details of FragmentScenario. "fragment-testing" declares Activity and is used by FragmentScenario. Activities declared in test APK runs in different process from APK under testing. In order to execute Fragment's code in the same process, you need to put "fragment-testing" library into your APK, not in test APK.)
Here's also a tutorial page in developers site.