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

During tests app crashes when trying to initialize WorkManager / WorkManager initializer is not invoked from androidx.startup.InitializationProvider #1026

Open
Roman-Markov opened this issue Jul 24, 2024 · 2 comments

Comments

@Roman-Markov
Copy link

Appium: 2.10.3
Espresso driver: 3.3.0

When I added dependency to app under test

implementation 'androidx.work:work-runtime:2.9.0'

and later in code invoked

WorkManager.getInstance(context);

the app started to crash during appium tests with espresso driver.

Exception:
java.lang.IllegalStateException: WorkManager is not initialized properly. You have explicitly disabled WorkManagerInitializer in your manifest, have not manually called WorkManager#initialize at this point, and your Application does not implement Configuration.Provider.

Merged manifest file of the app under test has it declared to be initialized via androidx.startup.InitializationProvider

        <provider
            android:name="androidx.startup.InitializationProvider"
            android:exported="false"
            android:authorities="com.example.android.testing.espresso.BasicSample.androidx-startup">

            <meta-data
                android:name="androidx.work.WorkManagerInitializer"
                android:value="androidx.startup" />
        </provider>

My custom provider was initialized and worked fine. Also I copied code from androidx.startup.InitializationProvider to my second custom provider. It could initialize WorkManger on app launch before WorkManager.getInstance(context); was invoked.

Here is repos to reproduce the crash:

A bit modified android espresso sample app: https://github.com/Roman-Markov/appium-espresso-reproducible-crash
Simple appium test code: https://github.com/Roman-Markov/simple-appium-test-to-reproduce-crash

@Roman-Markov
Copy link
Author

Similar issue:

When appium starts it prevents the initialisation of a RealmDB
#793

@awhiteraymarine
Copy link

@Roman-Markov Did you ever come up with a resolution to this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants