DHJJ [Hatsune's Journal Japan] blog

Hatsune's Journal Japan blog

目次

Blog 利用状況

ニュース

最新ツイート

運営サイト

Hatsune's Journal Japan
DHJJ

著作など

資格など

OCP
MCP

書庫

日記カテゴリ

わんくま同盟

[Xamarin]Xamarin.Androidで地図を使う

Google Maps Android API v2を利用できるようにする
Androidアプリ署名用キーストアからフィンガープリントを取得

コマンドプロンプトでkeytoolを起動しAndroidアプリ署名用キーストアからフィンガープリントを取得します。以下の説明では、デバッグ用のキーストアであるdebug.keystoreからフィンガープリントを取得する方法を説明しています。

アルファ版やベータ版を含めてストア登録して配布するためにはデバッグ用キーストアではなく、この時点で正式なAndroidアプリ署名用キーストアを指定します【作り方は次回)。

 

"C:\Program Files (x86)\Java\jdk1.6.0_39\bin\keytool.exe" ?list -v -keystore "C:\Users\hatsune\AppData\Local\Xamarin\Mono for Android\debug.keystore" -alias androiddebugkey -storepass android
-keypass android
別名: androiddebugkey
作成日: 2014/03/02
エントリタイプ: PrivateKeyEntry
証明連鎖の長さ: 1
証明書[1]:
所有者: CN=Android Debug, O=Android, C=US
発行者: CN=Android Debug, O=Android, C=US
シリアル番号: 5312ba0d
有効期間の開始日: Sun Mar 02 13:56:45 JST 2014 終了日: Fri May 29 13:56:45 JST 2
043
証明書のフィンガープリント:
         MD5:  A7:DC:■■:■■:■■:■■:■■:■■:■■:■■:■■:■■:■■:■■:■■:01
         SHA1: 67:5A:■■:■■:■■:■■:■■:■■:■■:■■:■■:■■:■■:■■:■■:■■:■■:■■:■■:0F
         署名アルゴリズム名: SHA1withRSA
         バージョン: 3
Google Developers Centerに作成するアプリ用のProjectを作成

image

Google Developers Consoleにログインして、[Create Project]ボタンをクリックします。

 

image

Project名を指定します。Project IDは自動的に生成されます。

image

 

APIの有効化

プロジェクト名をクリックしてoverviewを表示します。

image

[Enable an API]ボタンをクリックしてAPIリストを表示します。

 

「Maps」で絞り込んで、「Google Maps Android API v2」の行を見つけたら[OFF]ボタンをクリックしてSTATUSを[ON]にします。これでGoogle Maps Android API v2が有効になりました。

image

 

APIキーを取得する

[APIs & auth]-[Credentials]メニューを選択し、[Publis API access]にある[Create new Key]ボタンをクリックします。

image

 

Create a new key画面で[Android key]ボタンをクリックしてAndroid Keyの作成を開始します。

image

 

「keytoolで作成したSHA1フィンガープリント」+「;」+「パッケージ名」を入力してから[Create]ボタンをクリックします。

image

APIキーが表示されるので、これをAndroidManifest.xmlに転記します。

AndroidManifest.xmlの設定

image

Required Permissionsで次のものを選択します。

  • ACCESS_COARSE_LOCATION (GPS非利用時は指定不要)
  • ACCESS_FINE_LOCATION(GPS非利用時は指定不要)
  • ACCESS_MOCK_LOCATION(GPS非利用時は指定不要)
  • ACCESS_NETWORK_STATE
  • ACCESS_WIFI_STATE
  • INTERNET
  • WRITE_EXTERNAL_STORAGE

この状態でAndroidManifest.xamlは次のような内容になっています。

<?xml version="1.0" encoding="utf-8"?>
<manifest package="jp.hatsunejournal.AEDSearch" xmlns:android="http://schemas.android.com/apk/res/android" android:installlocation="auto" android:versioncode="1" android:versionname="1.0.1">
  <uses-sdk android:targetsdkversion="19" />
  <application android:icon="@drawable/Icon" android:label="AED検索">
  </application>
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>

あとは直接ファイルを開いて変更します。

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:installLocation="auto" package="jp.hatsunejournal.AEDSearch" android:versionCode="1" android:versionName="1.0.1">
  <uses-sdk android:targetSdkVersion="19" />
  <application android:label="AED検索" android:icon="@drawable/Icon">
    <!-- APIキーの設定 -->
    <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyCbwVTZ_mpWOVvnI3vke75QD9ZnheiMfCA" />
    <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
    <!-- -->
  </application>
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
  <uses-permission android:name="android.permission.INTERNET" />
  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  
  <!-- 権限の追加 -->
  <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
  
  <!-- OpenGL ESの設定-->
  <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
</manifest>

 

必要なAndroid SDKのインストール確認

今回はAndroid 4.2.2 (API17)をターゲットとしてアプリを作成します。4.2.2以外に、Google Play servicesなど必要なライブラリをAndroid SDK Mangerで導入しておきましょう。

image

Xamarin.Forms.Mapsコンポーネントの環境設定
Nugetでの導入

NugetでXamarin.Forms.Mapsを追加したら、必ず更新プログラムを確認して必要なライブラリを最新化します。

image

app.configの設定(2014年11月現在)

2014年11月現在の状況では、Xamarin.Forms.Maps導入後にapp.configにバージョン互換性の設定を行う必要があります。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Primitives" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.2.28.0" newVersion="4.2.28.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
コンパイルエラーの解消

ドキュメントやネット上の情報ではここまでやれば環境整備が完了と思っていましたが、実際にビルドすると

Unzipping failed. Please download 
https://dl-ssl.google.com/android/repository/google_play_services_5089000_r19.zip
 and extract it to the 
C:\User\Project\dotNET2013\WinRT\AEDSearchXamarin\packages\Xamarin.GooglePlayServices.19.0.0.1\lib\MonoAndroid23\19\content
 directory.

というようにunzipできないというエラーが発生して、unzipできないためにzipファイルの中身が電解できずに「google-play-services_lib/libs/google-play-services.jar」がないというビルドエラーが発生してしまい、ビルドできません。

これはzipファイルには実際に必要なjarファイル以外にもjavaファイルなど必須ではないファイルも含まれているのですが、この必須ではないファイルのフォルダ構造が深いためにパス名が長くなってしまいunzipできないという状態になっています。

 

そこで、zipファイルを取得して、それを所定の位置「<プロジェクトルート>\packages\Xamarin.GooglePlayServices.19.0.0.1\lib\MonoAndroid23\19\content」フォルダにフォルダ構造を維持して手作業で展開します。このときも同様にエラーが発生しますが、jarファイルだけ展開できればいいので、不必要なファイルの展開エラーは無視します。

 

これで再度ビルドすれば無事ビルド完了となります。

エミュレーターでの地図表示

image

現在、Android SDK、Genymotion、Xamarin Android Playerなどのエミュレーターのそれぞれの最新版の中でGoogle Play Serviceまで導入できて地図も表示できるのはXamarin Android Playerのようです。このあたりは、エクセルソフトの田淵さんのblogに詳しく載っています。

AED検索 for Androidもちゃんと地図が表示できます。

image

image

 

こんな感じでXamarin Formsで地図表示となるととても大変で、まだ本家のXAMLと比べると足りない点も多いのですが、ベータやアルファの状態を見るとこれからもXamarin Formsは拡充が続くようですので、最新動向に今後も注目していきたいと思います。

投稿日時 : 2014年12月13日 23:10

Feedback

# ivermectin 3mg tablets price 2021/09/28 10:24 MarvinLic

ivermectin lotion for lice http://stromectolfive.online# ivermectin uk coronavirus

# stromectol ivermectin tablets 2021/10/31 21:27 DelbertBup

ivermectin stromectol http://stromectolivermectin19.com/# ivermectin 18mg
ivermectin 18mg

# ivermectin 2mg 2021/11/01 15:03 DelbertBup

ivermectin 8 mg http://stromectolivermectin19.online# ivermectin generic name
ivermectin lotion for lice

# ivermectin syrup 2021/11/02 18:30 DelbertBup

price of ivermectin https://stromectolivermectin19.com/# ivermectin 4
ivermectin 1% cream generic

# ivermectin 200mg 2021/11/04 7:06 DelbertBup

ivermectin cream 5% https://stromectolivermectin19.com/# ivermectin 50ml
ivermectin usa price

# cost of prednisone 5mg tablets https://prednisonesnw.com/#
prednisone prescription for sale 2021/11/13 9:33 Prednisone

cost of prednisone 5mg tablets https://prednisonesnw.com/#
prednisone prescription for sale

# bimatoprost ophthalmic solution careprost 2021/12/12 1:03 Travislyday

http://baricitinibrx.online/ barinat

# bimatoprost generic 2021/12/13 16:05 Travislyday

https://bimatoprostrx.com/ best place to buy careprost

# bimatoprost buy online usa 2021/12/15 5:38 Travislyday

http://baricitinibrx.com/ barinat

# buy ivermectin nz 2021/12/17 17:17 Eliastib

mbxfmi https://stromectolr.com ivermectin 12 mg

# ivermectin 3 mg 2021/12/18 18:57 Eliastib

nfupzs https://stromectolr.com ivermectin 1

# ivermectin 3 mg tablet dosage 2022/02/18 2:16 FrankAwabe

https://stromectolst.com/# stromectol 6 mg tablet
ivermectin price canada

# ivermectin 1 topical cream 2022/02/20 21:05 EmanuelMeaks

https://stromectolis.com/# п»?order stromectol online

# buy cheap doxycycline https://doxycyline1st.com/
buy doxycycline hyclate 100mg without a rx 2022/02/26 17:48 Jusidkid

buy cheap doxycycline https://doxycyline1st.com/
buy doxycycline hyclate 100mg without a rx

# prednisone 2.5 mg tab https://prednisoneus.shop/ 2022/04/17 6:47 Prednisone

prednisone 2.5 mg tab https://prednisoneus.shop/

# lasix tablet https://buylasix.icu/
furosemide 100 mg 2022/06/25 1:05 LasixRx

lasix tablet https://buylasix.icu/
furosemide 100 mg

# Remeron https://allpharm.store/ 2022/07/22 5:59 AllPharm

Remeron https://allpharm.store/

# ivermectin warnings https://stromectolbestprice.com/ 2022/07/30 8:19 BestPrice

ivermectin warnings https://stromectolbestprice.com/

# cheap pet meds without vet prescription https://withoutdoctorprescription.xyz/
canadian medications 2022/09/07 17:33 IvanPres

cheap pet meds without vet prescription https://withoutdoctorprescription.xyz/
canadian medications

# ed medications online https://ed-pills.xyz/
gnc ed pills 2022/09/16 2:33 EdPills

ed medications online https://ed-pills.xyz/
gnc ed pills

# natural remedies for ed https://ed-pills.xyz/
male ed pills 2022/09/17 2:56 EdPills

natural remedies for ed https://ed-pills.xyz/
male ed pills

# vibramycin 100 mg https://buydoxycycline.icu/ 2022/10/08 17:13 Doxycycline

vibramycin 100 mg https://buydoxycycline.icu/

#  https://clomidforsale.site/ 2022/11/13 21:19 ForSale

https://clomidforsale.site/

# buy ed pills online https://cheapestedpills.com/
erection pills 2022/12/10 22:14 CheapPills

buy ed pills online https://cheapestedpills.com/
erection pills

# earch our drug database. Drug information.
https://edonlinefast.com
drug information and news for professionals and consumers. Read information now. 2023/02/18 2:27 EdOnline

earch our drug database. Drug information.
https://edonlinefast.com
drug information and news for professionals and consumers. Read information now.

# Prescription Drug Information, Interactions & Side. What side effects can this medication cause?
https://canadianfast.com/
Prescription Drug Information, Interactions & Side. Learn about the side effects, dosages, and interactions. 2023/02/20 11:51 CanadaBest

Prescription Drug Information, Interactions & Side. What side effects can this medication cause?
https://canadianfast.com/
Prescription Drug Information, Interactions & Side. Learn about the side effects, dosages, and interactions.

# buy doxycycline online without prescription - https://doxycyclinesale.pro/# 2023/04/21 23:22 Doxycycline

buy doxycycline online without prescription - https://doxycyclinesale.pro/#

# prednisone 54899 - https://prednisonesale.pro/# 2023/04/22 10:31 Prednisone

prednisone 54899 - https://prednisonesale.pro/#

# buy cytotec - https://cytotecsale.pro/# 2023/04/29 6:30 Cytotec

buy cytotec - https://cytotecsale.pro/#

# paxlovid for sale https://paxlovid.pro/# - paxlovid covid 2023/07/02 23:12 Paxlovid

paxlovid for sale https://paxlovid.pro/# - paxlovid covid

# Abortion pills online https://cytotec.ink/# - buy cytotec pills online cheap 2023/07/26 20:29 PillsFree

Abortion pills online https://cytotec.ink/# - buy cytotec pills online cheap

# paxlovid covid https://paxlovid.bid/ paxlovid generic 2023/10/26 0:36 Paxlovid

paxlovid covid https://paxlovid.bid/ paxlovid generic

# 100mg doxycycline https://doxycycline.forum/ generic doxycycline 2023/11/25 14:39 Doxycycline

100mg doxycycline https://doxycycline.forum/ generic doxycycline

# migliori farmacie online 2023 https://farmaciait.pro/ farmacie on line spedizione gratuita 2023/12/04 11:16 Farmacia

migliori farmacie online 2023 https://farmaciait.pro/ farmacie on line spedizione gratuita

# herbal ed treatment https://edpills.tech/# best ed treatment 2023/12/23 9:31 EdPills

herbal ed treatment https://edpills.tech/# best ed treatment

タイトル
名前
Url
コメント