wordpress-mobile / wordpress-mobile/WordPress-Android
[Screenshots] Hilt crash in `JPScreenshotTest`
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 3.2k
- Forks
- 1.4k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 69
Description
Parent: #17128
On some occasions, I get a Hilt crash when running the JPScreenshotTest
Reproducibility
This crash does not happen consistently (flaky), but still happens more often than not.
I haven't noticed this crash on the WPScreenshotTest yet; either I was very lucky, or there's something that makes it work in WPScreenshotTest but not in JPScreenshotTest that could give a hint at how to fix this?
Stacktrace
Example when running bundle exec fastlane screenshots app:jetpack locale:fr-FR (though I've seen it happen when running the test directly from Android Studio too)
[10:12:05]: $ /Users/olivierhalligon/Library/Android/sdk/platform-tools/adb -s emulator-5554 shell am instrument --no-window-animation -w \
-e testLocale fr-FR \
--no-hidden-api-checks \
-e appendTimestamp false \
-e class org.wordpress.android.ui.screenshots.JPScreenshotTest \
com.jetpack.android.test/org.wordpress.android.WordPressTestRunner
[10:12:10]: ▸ org.wordpress.android.ui.screenshots.JPScreenshotTest:
[10:12:10]: ▸ Process crashed while executing jPScreenshotTest(org.wordpress.android.ui.screenshots.JPScreenshotTest):
[10:12:10]: ▸ java.lang.IllegalStateException: The component was not created. Check that you have added the HiltAndroidRule.
[10:12:10]: ▸ at dagger.hilt.internal.Preconditions.checkState(Preconditions.java:83)
[10:12:10]: ▸ at dagger.hilt.android.internal.testing.TestApplicationComponentManager.generatedComponent(TestApplicationComponentManager.java:96)
[10:12:10]: ▸ at org.wordpress.android.WordPressTest_Application.generatedComponent(WordPressTest_Application.java:28)
[10:12:10]: ▸ at dagger.hilt.EntryPoints.get(EntryPoints.java:59)
[10:12:10]: ▸ at org.wordpress.android.WordPress.component(WordPress.kt:26)
[10:12:10]: ▸ at org.wordpress.android.push.GCMMessageService.onCreate(GCMMessageService.java:42)
[10:12:10]: ▸ at android.app.ActivityThread.handleCreateService(ActivityThread.java:3532)
[10:12:10]: ▸ at android.app.ActivityThread.access$1300(ActivityThread.java:199)
[10:12:10]: ▸ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1666)
[10:12:10]: ▸ at android.os.Handler.dispatchMessage(Handler.java:106)
[10:12:10]: ▸ at android.os.Looper.loop(Looper.java:193)
[10:12:10]: ▸ at android.app.ActivityThread.main(ActivityThread.java:6669)
[10:12:10]: ▸ at java.lang.reflect.Method.invoke(Native Method)
[10:12:10]: ▸ at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
[10:12:10]: ▸ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
[10:12:10]: ▸ Process crashed while executing jPScreenshotTest(org.wordpress.android.ui.screenshots.JPScreenshotTest):
[10:12:10]: ▸ java.lang.RuntimeException: Unable to create service org.wordpress.android.push.GCMMessageService: java.lang.IllegalStateException: The component was not created. Check that you have added the HiltAndroidRule.
[10:12:10]: ▸ at android.app.ActivityThread.handleCreateService(ActivityThread.java:3544)
[10:12:10]: ▸ at android.app.ActivityThread.access$1300(ActivityThread.java:199)
[10:12:10]: ▸ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1666)
[10:12:10]: ▸ at android.os.Handler.dispatchMessage(Handler.java:106)
[10:12:10]: ▸ at android.os.Looper.loop(Looper.java:193)
[10:12:10]: ▸ at android.app.ActivityThread.main(ActivityThread.java:6669)
[10:12:10]: ▸ at java.lang.reflect.Method.invoke(Native Method)
[10:12:10]: ▸ at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
[10:12:10]: ▸ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
[10:12:10]: ▸ Caused by: java.lang.IllegalStateException: The component was not created. Check that you have added the HiltAndroidRule.
[10:12:10]: ▸ at dagger.hilt.internal.Preconditions.checkState(Preconditions.java:83)
[10:12:10]: ▸ at dagger.hilt.android.internal.testing.TestApplicationComponentManager.generatedComponent(TestApplicationComponentManager.java:96)
[10:12:10]: ▸ at org.wordpress.android.WordPressTest_Application.generatedComponent(WordPressTest_Application.java:28)
[10:12:10]: ▸ at dagger.hilt.EntryPoints.get(EntryPoints.java:59)
[10:12:10]: ▸ at org.wordpress.android.WordPress.component(WordPress.kt:26)
[10:12:10]: ▸ at org.wordpress.android.push.GCMMessageService.onCreate(GCMMessageService.java:42)
[10:12:10]: ▸ at android.app.ActivityThread.handleCreateService(ActivityThread.java:3532)
[10:12:10]: ▸ ... 8 more
[10:12:10]: ▸ INSTRUMENTATION_RESULT: shortMsg=Process crashed.
[10:12:10]: ▸ INSTRUMENTATION_CODE: 0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running bundle exec fastlane screenshots app:jetpack locale:fr-FR and inspect JPScreenshotTest alongside WPScreenshotTest. Follow the stack from WordPress.kt through GCMMessageService and the Hilt test setup. Done means the flaky Hilt crash is reproduced or explained and JPScreenshotTest completes reliably.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java, kotlin
- Domain
- mobile, testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100