Soru & Cevap

android studio google maps api beyaz harita sorunu ...

11.09.2017 - 03:06

Merhabalar.

Android studioda hazır google maps activity kullanarak standart bir harita uygulaması yaptım. api keyide düzgün bir şekilde aldım ama uygulama emilatörde çalışırken harita açılıyo beyaz bir sayfa çıkıyo sol altta google yazısı çıkıyo. Bu sorunu nasıl çözebilirim. Kodlarım aşağıdaki şekilde

activity

package haritahamzadeneme3.com.haritahamzadeneme3;

import android.support.v4.app.FragmentActivity;
import android.os.Bundle;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
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 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);
    }


    /**
     * Manipulates the map once available.
     * This callback is triggered when the map is ready to be used.
     * This is where we can add markers or lines, add listeners or move the camera. In this case,
     * we just add a marker near Sydney, Australia.
     * If Google Play services is not installed on the device, the user will be prompted to install
     * it inside the SupportMapFragment. This method will only be triggered once the user has
     * installed Google Play services and returned to the app.
     */
    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;

        // Add a marker in Sydney and move the camera
        LatLng sydney = new LatLng(-34, 151);
        mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
        mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
    }
}

 

builg-d gradle

 

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'



        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

 

 

 

android manifest

 

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="haritahamzadeneme3.com.haritahamzadeneme3">

    <!--
         The ACCESS_COARSE/FINE_LOCATION permissions are not required to use
         Google Maps Android API v2, but you must specify either coarse or fine
         location permissions for the 'MyLocation' functionality. 
    -->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

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

        <!--
             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" />

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

 

 

google maps api xml

 

 

<resources>
    <!--
    TODO: Before you run your application, you need a Google Maps API key.

    To get one, follow this link, follow the directions and press "Create" at the end:

    https://console.developers.google.com/flows/enableapi?apiid=maps_android_backend&keyType=CLIENT_SIDE_ANDROID&r=CF:A3:1B:3E:21:71:6D:8C:3F:C0:2A:54:B1:5D:7F:B6:35:66:4E:69%3Bharitahamzadeneme3.com.haritahamzadeneme3

    You can also add your credentials to an existing key, using these values:

    Package name:
    CF:A3:1B:3E:21:71:6D:8C:3F:C0:2A:54:B1:5D:7F:B6:35:66:4E:69

    SHA-1 certificate fingerprint:
    CF:A3:1B:3E:21:71:6D:8C:3F:C0:2A:54:B1:5D:7F:B6:35:66:4E:69

    Alternatively, follow the directions here:
    https://developers.google.com/maps/documentation/android/start#get-key

    Once you have your key (it starts with "AIza"), replace the "google_maps_key"
    string in this file.
    -->
    <string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">AIzaSyD3-1ftXCXqvByVYotK-DSg72CaEC5ru6U</string>
</resources>

 

 

 

 

activity 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:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="haritahamzadeneme3.com.haritahamzadeneme3.MapsActivity" />

 

413 Görüntülenme

2 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

Profile picture for user Hamza3444
Hamza3444
11.09.2017 - 09:12
Hocam yardimin icin sagol ben hatayi cozdum. Api key alirken paket ismini eksik giriyormusum. Araya bir .com daha eklemem gerekiyormus onu duzelttim sorun cozuldu simdi calisiyo. Destegim icin sagol
picture-73270-1510122576.jpg
muratymn.72
11.09.2017 - 04:08

Selam Hamza,

ilk olarak  aşagıdaki yolu takip ederek Google Play Service Paketini indir. eğer var ise güncelle.

Tools/Android/Android SDK/SDK Tools yolunu izleyerek Google Play Service paketini indir.

google maps api xml içerisindeki api key anahtarını string içine al   "key"

<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">"AIzaSyD3-1ftXCXqvByVYotK-DSg72CaEC5ru6U"</string> 

hata devam ederse bilgilendir lütfen. iyi çalışmalar