我是一个Android / Java noob试图让我的Macbook上的Google Maps Android API示例与仿真器(Nexus 5X API 26)和Android Studio一起使用。
我复制了样本的github repo并将其加载到Android Studio中。现在,项目编译,我在模拟器上有应用程序,但地图似乎没有加载在片段中。
我还在onMapReady()上设置了一个断点,它确实被击中了。但片段是空白的。我该如何进一步调试?
答案 0 :(得分:0)
转到android manifest(示例项目)找到这一行。
<!--
The API key for Google Maps-based APIs is defined as a string resource.
(See the file "res/values/google_maps_api.xml").
Note that the API key is linked to the encryption key used to sign the APK.
You need a different API key for each encryption key, including the release key that is used to
sign the APK for publishing.
You can define the keys for the debug and release targets in src/debug/ and src/release/.
-->
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="@string/google_maps_key" />
在值文件夹中,您会发现google_maps_api.xml
会使用您的开发Google地图密钥更改google_maps_key
的值,因为在google_maps_api.xml
中明确提到了
Once you have your key (it starts with "AIza"), replace the "google_maps_key"
string in this file.
Note: This resource is used for the debug build target. Update this file if you just want to run
the demo app.
如果您尚未在Google开发者控制台https://developers.google.com/ad-exchange/rtb/open-bidder/google-app-guide中创建任何项目,请检查此链接
答案 1 :(得分:0)
I resolved it myself by switching from an emulator to a real phone.
Looks like some emulators don't come pre-loaded with Google Play services APK. That might have been the issue.