2017-12-31 70 views
0

私はGoogle Maps APIを使用していますが、リリースAPKの作成中に問題が発生しています。 Google Maps APIキーに問題があります。私たちを手伝ってくれますか?Google apiのキーが正しく動作しない空のGoogleマップの画面が表示される

コード

Androidmainfest.xml

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.placement.travelcompanier"> 
    <!-- 
     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="A*zaS**********************************" /> 


     <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 release your application, you need a Google Maps API key. 

    To do this, you can either add your release key credentials to your existing 
    key, or create a new key. 

    Note that this file specifies the API key for the release build target. 
    If you have previously set up a key for the debug target with the debug signing certificate, 
    you will also need to set up a key for your release certificate. 

    Follow the directions here: 

    https://developers.google.com/maps/documentation/android/signup 

    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">A*zaS**********************************</string> 
</resources> 

mapActivit y.java

package com.example.placement.travelcompanier; 

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(9.883813, 78.081907); 
     mMap.addMarker(new MarkerOptions().position(new LatLng(9.883813,78.081907)).title("My first marker")); 
     mMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(9.883813,78.081907))); 
    } 
} 

スクリーンショット: (その番組空白のマップページ)

enter image description here

+2

のためであることを確認し、状況を修正する方法の手がかりとともに地図を読み込めなかった場合、Googleマップは常にメッセージを記録します... – ariefbayu

+0

私の解決策はまだ見つかりません –

答えて

0

あなたのAPIキーがあなたのログメッセージを確認し、リリースモード

+0

私はそれを確認しました...まだ私は同じ問題があります –

関連する問題