Google 地图空白 Android

Google Maps blank in Android

我使用地图 api 在我的 Android 应用程序中集成了 Google 地图,但是当我启动它时它保持空白并且还显示 Google 徽标(见图) . this is what the app shows

In builde app gradle I have:
dependencies{
implementation 'com.google.android.gms:play-services-maps:11.0.4'
}
apply plugin: 'com.google.gms.google-services'

在manifest.xml我有:

<uses-permission android:name="com.vallabh.googlemapspractice.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="The Api Key which I got from google console" />

如果你使用android studio 试试这个,很容易解决问题 这里 android 工作室自动执行很多步骤。

新建google地图activity

  • 文件 -> 新建 -> Google -> Google 地图 Activity.

找到 google_maps_api.xml 文件

按照 TODO 步骤进行操作 在您 运行 您的应用程序之前,您需要一个 Google 地图 API 密钥。