I am new to Android application development and I am currently working on an existing Android application. From the Android documentation link https://developer.android.com/distribute/best-practices/develop/target-sdk it says that app updates must target at least Android 9.0.
So, I have set my targetSDKVersion to 28 and tried to run the application but restartLoader is not working as expected. The application is getting closed immediately when it tries to access the following line in the code.
this.getLoaderManager().restartLoader(1, params, this);
It works fine when I set the targetSDKVersion to 27. I have also found that the LoaderManager is deprecated in API level 28 and they have suggested to use the Support Library as mentioned in the link https://developer.android.com/reference/android/app/LoaderManager.
So I have migrated the entire project to AndroidX such that the restartLoader works fine but I am getting the same issue. I have made many changes to the dependencies of the build.gradle file as the one shown below but still the restartLoader is not working. I have tried setting many dependencies but it is of no use.
dependencies {
//implementation files('libs/android-support-v13.jar')
implementation "com.android.support:loader:28.0.0-alpha1"
implementation "com.android.support:support-fragment:28.0.0"
}
How can I fix the issue that is getting occurred when trying to access the restartLoader()
?