Posts

Showing posts with the label Androidx

Androidx.test.InstrumentationRegistry Is Deprecated

Answer : You can use InstrumentationRegistry.getInstrumentation().getTargetContext() in the most cases from androidx.test.platform.app.InstrumentationRegistry . If you need the Application, you can use ApplicationProvider.getApplicationContext<MyAppClass>() . If you haven't already, I think you can also use the new test dependency: androidTestImplementation 'androidx.test:core:1.0.0-beta02' . When you're using Android X you need to make sure you have the following in your app's build.gradle file androidTestImplementation 'androidx.test:core:1.1.0' androidTestImplementation 'androidx.test.ext:junit:1.1.0' The second one is to make sure you have the correct AndroidJUnit4 to use in your tests. Make sure you import both of these. import androidx.test.platform.app.InstrumentationRegistry import androidx.test.ext.junit.runners.AndroidJUnit4 Now instead of using val context = InstrumentationRegistry.getContext() you can use the lin...

AndroidX : Parcelable Encountered IOException Writing Serializable Object Only In Android Version 10 Devices

Answer : Here Is Your Solution : transient is a variables modifier used in serialization. At the time of serialization, if we don't want to save value of a particular variable in a file, then we use transient keyword. When JVM comes across transient keyword, it ignores original value of the variable and save default value of that variable data type. So, it uses quite rare in order to say to your compiler that this variable is not a part of serializable mathod.

Android WorkManager Worker Can Not Be Injected Using Dagger Hilt `@WorkerInject`

Answer : As per the WorkManager Configuration and Initialization documentation, to use the Configuration.Provider interface on your Application , you must remove the default initializer: <!-- In your AndroidManifest.xml --> <provider android:name="androidx.work.impl.WorkManagerInitializer" android:authorities="${applicationId}.workmanager-init" tools:node="remove" /> Otherwise, the default initializer will still run, wiping out your custom intialization and its HiltWorkerFactory .