Why Google Maps is showing empty screen in my Android App?

前端 未结 5 531
遇见更好的自我
遇见更好的自我 2021-01-06 17:30

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

5条回答
  •  隐瞒了意图╮
    2021-01-06 17:49

    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.


    1. Missing or incorrect or disabled API key

    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.

    • If it works, the key is not an issue.
    • If it doesn't work, the key is your issue.

    In such case make sure, you enabled it in Google API Console.


    2. Missing Android GMS version meta-data tag

    Your AndroidManifest.xml needs to define following metadata attribute:

    
    

    See the answer here for more details and official documentation.


    3. Missing user permissions

    In older versions of Android SDK, you had to explicitly set certain user permissions to work with Google Maps API correctly, for example:

    
    

    This is not the case anymore but I would recommend to visit official documentation to make sure you meet those version requirements.


    4. Requirement for OpenGL ES version 2

    In the past, there seemed to be requirement to specify following metadata attribute within AndroidManifest.xml

    
    

    This shouldn't be required anymore per official documentation. Some additional details are available e.g. here.


    5. AVD Manager device configurations

    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.

    • Try downgrading to lower SDK version.

    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..

提交回复
热议问题