Android Studio adds dependency on android.support.v4 package (solving V4 FragmentManager error)

Before adding:
Insert picture description here
1. Click this button on the project
Insert picture description here
2. Dependencies->app->Library Dependency
Insert picture description here
3. After searching and selecting the appropriate package, OK,
Insert picture description here
if the gradle is still gray,
Insert picture description here
select the project view and
Insert picture description here
change the two values ​​of gradle.properties to false
Insert picture description here
Switch back to the android view and click Sync immediately. The
Insert picture description here
dependency import is successful.
Insert picture description here
If the incompatible types:required:androidx.fragment.app.fragmentManager...error occurs during synchronization, add the following to the manifest file:

 android:appComponentFactory=""
 tools:replace="android:appComponentFactory"

If getSupportFragmentManager() still has an error, pay attention to the following three points:
1. Inherit FragmentActivity
2. Define FragmentManager to android.support.v4.app.FragmentManager
3. Change the method getFragmentManager() to getSupportFragmentManager()
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_43873198/article/details/108895904