2017-12-31 20 views
0

Google지도 API를 사용 중이며 출시 APK를 만드는 동안 문제가 있습니다. 내 Google지도 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

나는 그것을 검증했다. .. 아직도 나는 같은 이슈를 가지고있다. –

관련 문제