0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

AndroidStudioでGoogleMapsAPI を触れるようにしたので自分用メモ

Posted at

初めに

自分がAndroidでGoogleMapAPIを触れるようにした手順のメモです。
一応windowsならほかの環境でも大丈夫なはず。

事前準備

AndroidStudioをインストールして、適当なプロジェクトを作成しておく。

手順

google APIのアクセスキーを取得する

  1. Google Cloud Platform Console にアクセス
  2. 初回アクセス時(おそらく)は国と同意が求められるので、同意して続行
  3. 検索からGoogle Map Platformにアクセス
  4. 左のメニューからAPIを選択
  5. 無料トライアルを開始する鵜
  6. "Maps SDK for Android" をクリック
  7. 『有効にする』ボタンをクリックすると、『APIを有効にしています』というメッセージが出るのでしばらく待機
  8. 有効になったら『認証情報』をクリック
  9. 『認証情報を作成』をクリックし、展開されるサブメニューから『APIキー』をクリック
  10. API キーが発行されるので、コピー

AndroidStudioに設定する

  1. valuesにapi_keys.xmlを作成
  2. <string name="google_maps_key" translatable="false" templateMergeStrategy="preserve">{APIキー}</string> を追加
  3. マニュフェストに <meta-data
    android:name="com.google.android.geo.API_KEY"
    android:value="@string/google_maps_key" />
    を追加
  4. gradleに implementation 'com.google.android.gms:play-services-maps:18.1.0' を追加

SHA1証明書のフィンガープリントを取得する

  1. JDKをインストールしていない場合は、インストールを行う
  2. c:\Program Files\Java{jdk}\binまで移動する
  3. keytool.exe -list -v -keystore "c:\Users(ユーザー名).android\debug.keystore" を実行
  4. パスワードの入力が求められるので入力(初期はandroid)
  5. 表示されたSHA1証明書のフィンガープリントをコピー

API キーを保護する

  1. Google Cloud Platform Console でAPIキーを保護することを進められる
  2. Select restriction typeにAndroidアプリを指定
  3. パッケージ名を設定

参考記事(手順の部分はほぼ)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?