So, I was trying to use fragment testing library
androidx.fragment:fragment-testing:1.2.4 in a dynamic feature module. When I used Android Gradle Plugin (AGP) version
3.6.3, it failed to build with an error
AAPT: error: resource style/FragmentScenarioEmptyFragmentActivityTheme (aka com.example.reminder.test:style/FragmentScenarioEmptyFragmentActivityTheme) not found.
And so I was curious and checkout the codelab github and try to upgrade the AGP on that project to
3.6.3 and it can build successfully. But the codelab does not use Dynamic Features.
So I tried to actually run a fragment test in my
app module only (excluding the dynamic features module) and yes it can build successfully too. But I still need to test my fragment in the dynamic features module, so I tried playing with the version one by one and then when I downgrade the AGP version to
3.4.1 it can build successfully.
And I found out that since AGP version
3.5.0 and above, it just failed to build with the same error above.
AGP 3.5.0 and above: - Building test on app module only -> works - Building test on dynamic features -> failed to build AGP 3.4.2 and below: - Building test on app module only -> works - Building test with dynamic features -> works
But I still want to use AGP
3.6.0 because I want to utilise viewBinding.
So does anyone know how to resolve the error above for fragment testing with dynamic features module?
Upgrading AGP to
4.0.0 and above should resolve the issue.
Answered By – Michael