Google google map problems

综合技术 2018-03-15 阅读原文

I am currently building an android app. I understand the basics and I did a number of apps but now my project is bigger. My app include a number of screens with NavigationDrawer included which forces me to use an extension of Fragment class on every class I want to be displayed on my application. Here is my problem -some time ago I create an app a simple one page google maps screen and it works just fine. I want to do the same thing on the app I am currently working on but all it gives me when I go to the page is the google log at the bottom left screen and the rest is grey like view (no map is displayed).I searched for solution in a lot of places including this site and I could get as an answer was that it might have to do with my API key given to me by google.I ckecked that and I am pretty sure it is not from the key because I applied it on my one page google map app and it worked perfect.I also have all the permissions needed I checked that like 6 times.So my conclusion is there is something in the code that is preventing the map to be displayed.

Here is my code:

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;

public class guide extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // inflat and return the layout
        View v = inflater.inflate(R.layout.test, container,
                false);

        return v;
    }

    class HoldFragmentPlace extends FragmentActivity{

        private GoogleMap mMap;

        public HoldFragmentPlace(){

        }

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // inflat and return the layout
        View v = inflater.inflate(R.layout.test, container,
                false);

        return v;
    }

    @Override
    protected void onResume() {
        super.onResume();
        setUpMapIfNeeded();
    }

    private void setUpMapIfNeeded() {
        // Do a null check to confirm that we have not already instantiated the map.
        if (mMap == null) {
            // Try to obtain the map from the SupportMapFragment.
            mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map))
                    .getMap();
            // Check if we were successful in obtaining the map.
            if (mMap != null) {
                setUpMap();
            }
        }
    }

        private void setUpMap() {
            mMap.addMarker(new MarkerOptions().position(new LatLng(0, 0)).title("Marker"));
        }

    }

}

I need that Fragment extension for my NavigationDrawer to work so I create an inner class and applied the code for the map there.

Here is what I have in my manifest:








And here is my xml for the map:



    

I also tried a few other variations of the java code some of them does not include inner class and the result is still the same.I am either missing something very fundamental or I am misunderstanding some conception about Android.If you have read all that thank you for the spared time!

Check the APK signing. You have to assign a debug API key in testing and a Release API key when releasing APK. Insert the correct API key, clean and rebuild your project.

I've been there a year a go and I can assure that this was the problem. Double check your key and if it's a debug or release key.

Another thing to check is the package name of your app... Let me know if you did and still get the grey view instead of the

UPDATE:

I was trying to include everything when I realized that your problem is only in the signing phase.

You only need to get the SHA-1 fingerprint
of the debug keystore
and put it in your API Key dialog. And trust me there's nothing I can write that can be more clear and informative than the Google documentation.

Follow the steps in this link
to get the debug certificate
and the SHA-1 fingerprint
.

UPDATE 2:

In order to get the SHA-1 of the keystore you might check this thread .

Hello, buddy!

责编内容by:Hello, buddy!阅读原文】。感谢您的支持!

您可能感兴趣的

Java Time Picker dialog box hey I am trying to make a TimepickerDialog. But the app crashes soon as I press the Set Time button. Here is the code. MainActivity: package com.w...
app的好用框架 Android 屏幕直播方案 项目需求是实时同步 Android 手机屏幕画面至浏览器。这里有两个挑战,一是 Android 如何在应用内获得屏幕实时视频流,另一个是如何在浏览器上做视频直播。经过一番折腾,确定了如下的实现方案。期间,我们也实现了手机摄像头的直播。 ...
Android OS boot process with focus on Zygote No Comments You just started with Android development and went through setup new project wizard in Android Studio, pressed that glorious green pl...
Android ConstraintLayout — Build a layout from Scr... I’ve seen quite a lot of misuse/misunderstanding of how to use ConstraintLayout practically. I was contemplating the best way to talk about these comm...
RxJava再回首 废话几句 很早前就看了RxJava,当时就觉得好牛掰,但是公司项目一直没有用起来,知识不用就会忘,前段时间突然要写RxJava,发现已经不会写了。所以今天再回头整理一下RxJava的头绪,一方面给其它想了解RxJava的人提供参考,另一方面也是给自己将来再遗忘时回来翻阅。 1、RxJava是...