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

Tests sometimes fail with "IllegalStateException: The component was not created" #932

Closed
rfc2822 opened this issue Jul 23, 2024 · 1 comment · Fixed by #939
Closed

Tests sometimes fail with "IllegalStateException: The component was not created" #932

rfc2822 opened this issue Jul 23, 2024 · 1 comment · Fixed by #939
Assignees
Labels
bug Something isn't working

Comments

@rfc2822
Copy link
Member

rfc2822 commented Jul 23, 2024

Sometimes, tests randomly fail with:

at.bitfire.davdroid.sync.SyncManagerTest > testPerformSync_503RetryAfter_DelaySeconds[virtual] FAILED 
	java.lang.IllegalStateException: The component was not created. Check that you have added the HiltAndroidRule.
		at dagger.hilt.internal.Preconditions.checkState(Preconditions.java:83)

virtual Tests 84/132 completed. (0 skipped) (1 failed)
Finished 84 tests on virtual

> Task :app:virtualOseDebugAndroidTest
Tests on virtual failed: There was 1 failure(s).
Test run failed to complete. Instrumentation run failed due to Process crashed.
Logcat of last crash: 
Process: at.bitfire.davdroid, PID: 1957
java.lang.RuntimeException: Unable to create service at.bitfire.davdroid.sync.OpenTasksSyncAdapterService: java.lang.IllegalStateException: The component was not created. Check that you have added the HiltAndroidRule.
	at android.app.ActivityThread.handleCreateService(ActivityThread.java:4664)
	at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2264)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:205)
	at android.os.Looper.loop(Looper.java:294)
	at android.app.ActivityThread.main(ActivityThread.java:8177)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: java.lang.IllegalStateException: The component was not created. Check that you have added the HiltAndroidRule.
	at dagger.hilt.internal.Preconditions.checkState(Preconditions.java:83)
	at dagger.hilt.android.internal.testing.TestApplicationComponentManager.generatedComponent(TestApplicationComponentManager.java:96)
	at dagger.hilt.android.testing.HiltTestApplication.generatedComponent(HiltTestApplication.java:50)
	at dagger.hilt.EntryPoints.get(EntryPoints.java:59)
	at dagger.hilt.android.internal.managers.ServiceComponentManager.createComponent(ServiceComponentManager.java:70)
	at dagger.hilt.android.internal.managers.ServiceComponentManager.generatedComponent(ServiceComponentManager.java:58)
	at at.bitfire.davdroid.sync.Hilt_OpenTasksSyncAdapterService.generatedComponent(Hilt_OpenTasksSyncAdapterService.java:58)
	at at.bitfire.davdroid.sync.Hilt_OpenTasksSyncAdapterService.inject(Hilt_OpenTasksSyncAdapterService.java:52)
	at at.bitfire.davdroid.sync.Hilt_OpenTasksSyncAdapterService.onCreate(Hilt_OpenTasksSyncAdapterService.java:29)
	at android.app.ActivityThread.handleCreateService(ActivityThread.java:4651)
	... 9 more

Usually this happens in testPerformSync_503RetryAfter_DelaySeconds, but only in a few percent of the runs and I think sometimes at other locations/during other tests.

Re-running the failed test usually succeeds.

@rfc2822 rfc2822 added the bug Something isn't working label Jul 23, 2024
@rfc2822 rfc2822 self-assigned this Jul 24, 2024
@rfc2822 rfc2822 linked a pull request Jul 24, 2024 that will close this issue
@rfc2822
Copy link
Member Author

rfc2822 commented Jul 24, 2024

Still happens (davx5):


> Task :app:virtualStandardDebugAndroidTest
Starting 132 tests on virtual

at.bitfire.davdroid.sync.SyncManagerTest > testPerformSync_503RetryAfter_DelaySeconds[virtual] FAILED 
	java.lang.IllegalStateException: The component was not created. Check that you have added the HiltAndroidRule.
		at dagger.hilt.internal.Preconditions.checkState(Preconditions.java:83)

virtual Tests 84/132 completed. (0 skipped) (1 failed)

> Task :app:virtualStandardDebugAndroidTest
Tests on virtual failed: There was 1 failure(s).

Finished 84 tests on virtual

> Task :app:virtualStandardDebugAndroidTest FAILED
Test run failed to complete. Instrumentation run failed due to Process crashed.
Logcat of last crash: 
Process: at.bitfire.davdroid, PID: 1921
java.lang.RuntimeException: Unable to create service at.bitfire.davdroid.sync.OpenTasksSyncAdapterService: java.lang.IllegalStateException: The component was not created. Check that you have added the HiltAndroidRule.
	at android.app.ActivityThread.handleCreateService(ActivityThread.java:4664)
	at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2264)
	at android.os.Handler.dispatchMessage(Handler.java:106)
	at android.os.Looper.loopOnce(Looper.java:205)
	at android.os.Looper.loop(Looper.java:294)
	at android.app.ActivityThread.main(ActivityThread.java:8177)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
Caused by: java.lang.IllegalStateException: The component was not created. Check that you have added the HiltAndroidRule.
	at dagger.hilt.internal.Preconditions.checkState(Preconditions.java:83)
	at dagger.hilt.android.internal.testing.TestApplicationComponentManager.generatedComponent(TestApplicationComponentManager.java:96)
	at dagger.hilt.android.testing.HiltTestApplication.generatedComponent(HiltTestApplication.java:50)
	at dagger.hilt.EntryPoints.get(EntryPoints.java:59)
	at dagger.hilt.android.internal.managers.ServiceComponentManager.createComponent(ServiceComponentManager.java:70)
	at dagger.hilt.android.internal.managers.ServiceComponentManager.generatedComponent(ServiceComponentManager.java:58)
	at at.bitfire.davdroid.sync.Hilt_OpenTasksSyncAdapterService.generatedComponent(Hilt_OpenTasksSyncAdapterService.java:58)
	at at.bitfire.davdroid.sync.Hilt_OpenTasksSyncAdapterService.inject(Hilt_OpenTasksSyncAdapterService.java:52)
	at at.bitfire.davdroid.sync.Hilt_OpenTasksSyncAdapterService.onCreate(Hilt_OpenTasksSyncAdapterService.java:29)
	at android.app.ActivityThread.handleCreateService(ActivityThread.java:4651)
	... 9 more

@rfc2822 rfc2822 reopened this Jul 24, 2024
@rfc2822 rfc2822 closed this as completed Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant