I have Google Maps in my Android App. I added it by selecting new Google Maps Activity & pasting the key in Android Studio. It worked fine in my Android phone (Lenovo K5
Fought with blank map past two days and here is the summary (which I'm sure is not a complete list of possible issues!) collected from various sources.
Seems to be most often. I recommend to follow official documentation. If you finish all steps, issue persists and you're still unsure whether it could be the reason, clone official android samples, find the MapWithMarker sample (android-samples/tutorials/MapWithMarker) and test against it. If you run the sample and it shows the map correctly, try to exchange default API KEY for the one you own.
In such case make sure, you enabled it in Google API Console.
Your AndroidManifest.xml needs to define following metadata attribute:
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
See the answer here for more details and official documentation.
In older versions of Android SDK, you had to explicitly set certain user permissions to work with Google Maps API correctly, for example:
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
This is not the case anymore but I would recommend to visit official documentation to make sure you meet those version requirements.
In the past, there seemed to be requirement to specify following metadata attribute within AndroidManifest.xml
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
This shouldn't be required anymore per official documentation. Some additional details are available e.g. here.
Android Studio 3.0 AVD Manager allows you to create device configurations for APIs that don't seem to be working well. At the moment, you can create configuration against API v27 which doesn't seem to be released yet if I'm not mistaken. Basic emulations worked well even there until I started work with Google Maps API. None of the device configurations set to v27 worked with Maps API resulting in blank map.
Note: Would be happy if anyone with deeper knowledge correct my simplified and probably incorrect interpretation. Since this was my problem, I stopped evaluating deeper and simply switch to different configuration for now.
Using following setup:
Android Studio 3.0
Build #AI-171.4408382, built on October 20, 2017
JRE: 1.8.0_152-release-915-b01 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
Hope this will help at least one person to save some time..
I had similar problem and spent a lot of time before solving it. Usually all was OK on real device, but failed to show Google Map on some of my emulator variants. Obviously, the program code was OK, so the question was why?
What I observe so far:
If hardware acceleration is disabled - all is back working.
If use pure android image, cpu-arm (not accelerated x86, it was slower), but also works.
If you are under x86_64 OS - macOS 10.13.2 in my case, USE x86_64 version of emulator image, instead of universal x86!!! That was my mayor mistake to do not get it works! Replacing my emulator's image with x86_64 variants, solve all of them!
The debug.keystore is different from two computers.
Solutions:
1) Copy the keystore from the pc to new in Android folder.
2) Generate new sha and put in your google api's project. https://developers.google.com/maps/documentation/android-api/signup#release-cert
I think the SHA1 key you used to develop the app on pc is creating this problem on another pc. Generate SHA1 on new pc and replace old one then it will work fine. As you are using it as debugging purposes. For production purposes there is documentation on developer page.
Given the fact that your app works on Lenovo
, the most probable cause is that your Coolpad
phone doesn't have Google Play services
which are mandatory when you use most of Google's products. (here you can find more details about this problem for Coolpad 8675
). Unfortunately, you can't fix this as a developer. If an user really wants to user your app and doesn't have the Play Services
you can show an error telling what's the problem and that they should install them before using your app. From this point, they should be able to find enough tutorials on how to do this thing.