launchFragmentInHiltContainer does not appear to work with the 1.2.0-beta02 of androidx.activity/androidx.fragment: "Cannot access 'EmptyFragmentActivity': it is internal in 'FragmentScenario'"
See original GitHub issueAfter updating androidx.activity:activity-ktx and androidx.fragment:fragment-ktx to 1.2.0-beta02 from 1.2.0-beta01, the launchFragmentInHiltContainer code example found here and recommended here does not appear to work.
Cannot access 'EmptyFragmentActivity': it is internal in 'FragmentScenario' e: /home/runner/work/libraries/test-config/src/debug/java/com/xxx/test_config/HiltExtensions.kt: (25, 42): Public-API inline function cannot access non-public-API 'public const final val THEME_EXTRAS_BUNDLE_KEY: String defined in androidx.fragment.app.testing.FragmentScenario.EmptyFragmentActivity.Companion' Task :libraries:test-config:compileDevDebugKotlin FAILED
Issue Analytics
- State:
- Created 3 years ago
- Reactions:5
- Comments:6
Top Results From Across the Web
FragmentScenario.EmptyFragmentActivity isn't available in ...
When I wanted to implement this method for creating an annotated activity for hilt testing I faced not accessing the EmptyFragmentActivity.
Read more >Test your fragments - Android Developers
FragmentScenario includes the following methods for launching fragments in tests: launchInContainer() , for testing a fragment's user interface.
Read more >fragment/fragment-testing/src/main/java/androidx ... - Google Git
you may not use this file except in compliance with the License. ... FragmentScenario<F> = launchFragment(fragmentArgs, themeResId) {. instantiate(). }.
Read more >Fragment Scenario has no way to trigger ... - Issue Tracker
Component used: Fragment Version used: 1.1.0-alpha02. Devices/Android versions reproduced on: emulator. I am trying to test that a menu option is enabled or ......
Read more >Testing Fragments with Dagger-Hilt - Part 12 - YouTube
In this video I will show you a workaround to be able to test fragments with the help of Dagger-Hilt.⭐ Get certificates for...
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
I can replicate using
fragment-ktx 1.3.0-beta2
. As suspected, it’s becauseEmptyFragmentActivity
is now internal.If you don’t need to pass in your own theme, then remove
themeResId
from the parameters of the function and the.putExtra
lines of thestartActivityIntent
.If you need it, then use the fully qualified key that you can find in the implementation of
EmptyFragmentActivity
. i.e.That’s a nasty workaround but that’s all we can do for now
The architecture-samples project use the stable version of
androidx.fragment:fragment-ktx:1.2.0
. As you’re using a lower version, I’d suggest modifying thelaunchFragmentInHiltContainer
yourself. Remove thethemeResId
param (line 40) and theputExtra
method that sets it (line 48).Thanks!