###前提・実現したいこと
AndroidStudioを使用してGoogleMapの表示をしようとしているのですが、
http://kanapplabo.seesaa.net/article/432685739.html
上記のサイトを参考に作成したところ、エラーが発生しいろいろ試したのですが、解決できませんでした。
###発生している問題・エラーメッセージ
10-07 23:07:44.653 23737-24156/com.example.ready.cho_shien E/b: Authentication failed on the server.
10-07 23:07:44.653 23737-24156/com.example.ready.cho_shien E/Google Maps Android API: Authorization failure. Please see https://developers.google.com/maps/documentation/android-api/start for how to correctly set up the map.
10-07 23:07:44.655 23737-24156/com.example.ready.cho_shien E/Google Maps Android API: In the Google Developer Console (https://console.developers.google.com)
Ensure that the "Google Maps Android API v2" is enabled. Ensure that the following Android Key exists: API Key: [APIKEY] Android Application (<cert_fingerprint>;<package_name>): [SHA-1];com.example.ready.cho_shien
###MainActivity.java
package com.example.ready.cho_shien;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
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 {
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_maps); SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map); mapFragment.getMapAsync(this); } @Override public void onMapReady(GoogleMap map) { // Add a marker in Sydney, Australia, and move the camera. LatLng sydney = new LatLng(-34, 151); map.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney")); map.moveCamera(CameraUpdateFactory.newLatLng(sydney)); }
}
###google_map_api.xml
<resources>
<!--
TODO: Before you run your application, you need a Google Maps API key.
</resources>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= [SHA-1]%3Bcom.example.ready.cho_shien You can also add your credentials to an existing key, using this line: [SHA-1];com.example.ready.cho_shien 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">[APIKEY]</string>
###activity_maps.xml
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
tools:context=".MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment" />
###試したこと
パッケージ名やSHA-1コードがgoogle MAPS APIに間違いなく登録されているか確認しました。
AndroidStudioに書くAPICODEも間違いなく入力できています。
###補足情報(言語/FW/ツール等のバージョンなど)
Android6.0(NEXUS5)実機で動作させています。
AndroidStudio2.2を使用しています。(2.1.1でも同じく動作しませんでした。)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/10/08 08:22