Google maps are not displayed on my real device [duplicated]

0

When I generate the APK on my cell phone it does not show google map.

My class:

public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {

    private GoogleMap mMap;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_maps);
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);
    }


    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;

        // Add a marker in Sydney and move the camera
        LatLng jockey = new LatLng(-33.852, 151.211);
        mMap.addMarker(new MarkerOptions().position(jockey).title("Signey"));
        mMap.moveCamera(CameraUpdateFactory.newLatLng(jockey));
    }
}

My xml:

<fragment

    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:map="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    tools:context="com.example.mauri.googlemapsandroid2.MapsActivity">


</fragment>

my manifest: In the manifest I put all the corresponding permissions and call the Api key.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.mauri.googlemapsandroid2">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />
        <activity
            android:name=".MapsActivity"
            android:label="@string/title_activity_maps">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

I already created my credentials in the Google maps, I generated the API_KEY , and the SHA1 but it still does not appear on my real device. Only the word Google appears in the lower left.

I'm trying to try and nothing. Someone to give me a help please

    
asked by Mauriho Enrique Escurra Colqui 04.11.2017 в 17:58
source

2 answers

1

Apparently you did not configure the xml; google_maps_api.xml  it is found in; Vaules / google_maps_api.xml

This file is a link, this will take you to some steps where you generated your Key through Google API Console . That key or key you must paste it in the file xml already mentioned in the beginning.

It would stay like this

<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">
        //Tu clave va en este lugar ...
    </string>

And if your problem is no longer resolved, I think you should check your connection, it's never the rest.

    
answered by 04.11.2017 в 20:00
0

Place the API_KEY in the manifest and try to compile, usually if it is in the google_maps_api.xml file.

It is not loaded when compiling the apk , another point that you must take into account is that the console of google API , takes into account the SHA1 generated by the android studio where you are doing your project, by experience, if you change your pc, you must generate a new activity maps and generate your api key again, and thus you will not have problems.

    
answered by 11.12.2018 в 16:43