2016-07-05 12 views
1

noch habe ich ein anderes Problem mit meiner Android-App Ich entwickelte eine ziemlich grundlegende Anwendung, die eine einzige Aktivität enthält und Google Maps (ich verwendete Google Maps API). Die Kompilierung endet ohne Fehler, ich erzeuge auch die apk ohne Probleme, aber wenn ich meine Anwendung auf verschiedenen Geräten ausführen, wird nur eine leere Seite mit dem Google-Zeichen unter dieser Seite angezeigt.Ich brauche Hilfe für Google Map API

[![This the screenshot of my application][1]][1] 


package com.example.amine.bea_mapapp; 

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)); 
    } 
    } 

<string name="google_maps_key" templateMergeStrategy="preserve" translatable="false">My API key is here</string> 

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="com.example.amine.bea_mapapp"> 
<permission android:name="com.androidcom.example.amine.bea_mapapp.MAPS_RECEIVE" android:protectionLevel="signature"/> 
<uses-permission android:name="com.androidcom.example.amine.bea_mapapp.MAPS_RECEIVE"/> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> 
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> 
<uses-permission android:name="android.permission.INTERNET"/> 
<uses-permission android:name="com.androidcom.example.amine.bea_mapapp.providers.gsf.permission.READ_GSFREVICES"/> 
<uses-feature android:glEsVersion="0x00020000" 
    android:required="true"/> 

<application 
    android:allowBackup="true" 
    android:icon="@mipmap/ic_launcher" 
    android:label="@string/app_name" 
    android:supportsRtl="true" 
    android:theme="@style/AppTheme"> 

    <meta-data 
     android:name="com.google.android.geo.API_KEY" 
     android:value="My API key is here" /> 

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

+1

Suchen Sie in den Protokollen nach Fehlern im Zusammenhang mit dem API-Schlüssel –

+0

welche Apk-Datei Sie generiert ..? signierte apk oder Debug apk ..? –

Antwort

1

scheint Probleme mit dem API-Schlüssel Google. Welche Schlüssel verwenden Sie bei

<meta-data 
     android:name="com.google.android.geo.API_KEY" 
     android:value="My API key is here" /> 

Wenn noch mit Problem zu kämpfen, erzeugen Sie einen neuen Google Map API-Schlüssel mit einem Schlüsselspeicher von Ihrem Gerät erzeugt und baut apk mit diesem neuen MAP-API-Schlüssel. Ich bin sicher, dass es dann in allen Geräten funktioniert.

1

Das erste, was müssen Sie Google-Konto in diesem Gerät oder nicht zweite Sache Prüfung angemeldet überprüfen eingebaute Karte in Ihrem Testgerät Fein- oder nicht funktioniert. Da Google Map auf einige Dienste aus dem Gerät bestehenden Kartenanwendung und Ihrem Google-Konto zugreifen.

+0

Ja, diese Dinge sind für Ihre Karte in Android-Anwendung obligatorisch. – Ramkailash