我们如何找到 google_maps_api.xml 文件

How do we locate the google_maps_api.xml file

Get a Google Maps API key

Your application needs an API key to access the Google Maps servers. The type of key you need is a Key for Android applications. The key is free. You can use it with any of your applications that call the Google Maps Android API, and it supports an unlimited number of users.

Choose one of the following ways to get your API key:

The fast, easy way: Use the link provided in the google_maps_api.xml file that Android Studio created for you:
    Copy the link provided in the google_maps_api.xml file and paste it into your browser. The link takes you to the Google

Developers Console and supplies information via URL parameters, thus reducing the manual input required from you. Follow the instructions to create a new project on the console or select an existing project. Create an Android API key for your console project. Copy the resulting API key, go back to Android Studio, and paste the API key into the element in the google_maps_api.xml file.

我想知道我们如何找到该文件。它位于哪里?

转到 res > values > google_maps_api.xml 在这里你会找到这个

调试键:app > src > debug > res > values > google_maps_api.xml 释放键:app > src > relese > res > values > google_maps_api.xml

在Android Studio 3.0+ 中,当您签署apk 时,release 和debug 文件夹不包含任何google_maps_api.xml。我不知道为什么?

但你只是简单地将元数据放入 AndroidManifest.xml

   <meta-data
                android:name="com.google.android.geo.API_KEY"
                android:value="@string/API_KEY"/>

并正确签署您的 apk, - 设置包名称 - Google 开发者控制台的 SHA1 密钥(此处需要 上传密钥应用程序签名密钥 google

查看我的详细答案:

Debug build place key in

app > src > debug > res > values > google_maps_api.xml

并在

中发布构建放置密钥

app > src > relese > res > values > google_maps_api.xml

也可以直接放在strings.xml或者manifest里

  <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="@string/google_maps_key"/>

 <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="Aiza.._complete_your_key"/>