如何在Android Studio 3.3 canary 13 中使用MapView?

How to use MapView in Android Studio 3.3 canary 13?

我正在使用 Android Studio 3.3 canary 13。应用程序崩溃并显示此消息。

我收到这个错误:

Caused by: android.view.InflateException: Binary XML file line #274: Binary XML file line #274: Error inflating class com.google.android.gms.maps.MapView
Caused by: android.view.InflateException: Binary XML file line #274: Error inflating class com.google.android.gms.maps.MapView
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.maps.MapView" on path: DexPathList[[zip file .

任何人都可以帮助了解如何在 AndroiX 中使用 MapView 吗?

有问题的 XML 行:

<com.google.android.gms.maps.MapView
    android:id="@+id/map_view"
    android:layout_width="0dp"
    android:layout_height="140dp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toBottomOf="@id/tv_address"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintVertical_bias="0"
    android:layout_marginTop="16dp"
    />

可能是这项工作,只需在您的AndroidManifast.xml

中定义

首先添加:-

<meta-data
     android:name="com.google.android.maps.v2.API_KEY"
     android:value="AIzaSyC6TVk6gtR_i_.......**************"/>

然后:-

<meta-data 
     android:name="com.google.android.maps.v2.API_KEY"
     android:value="@integer/your_google_maps_version" />