androidX迁移后无法实例化片段com.google.android.gms.maps.SupportMapFragment

Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment after migration of androidX

迁移 androidX 后出现此错误

   <fragment
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:name="com.google.android.gms.maps.SupportMapFragment"/>

Caused by: android.view.InflateException: Binary XML file line #39: Error inflating class fragment Caused by: androidx.fragment.app.Fragment$InstantiationException: Unable to instantiate fragment com.google.android.gms.maps.SupportMapFragment: calling Fragment constructor caused an exception

您必须使用 SupportMapFragment migrated 从 Android 支持库到 AndroidX 库。

如果您使用此版本或更高版本。

com.google.android.gms:play-services-maps:17.0.0

如果您查看文档,它会扩展 androidx.fragment.app.Fragment