3

Android アプリに Google マップ フラグメントを実装する際に深刻な問題があります。基本的に、Google の Web サイトのすべての指示に従いました。Google Maps API v2 キーを取得し、レイアウトとマニフェストを設定し、google-play-service ライブラリをインポートして、Google のサンプル コードを使用して GoogleMap を起動した後、エミュレーターが Google Maps API v2 をサポートしていないことがわかったので、オンラインになり、com.android.vending.apk と com.google.android.gms.apk の最新バージョンをダウンロードしてから、adb install を使用してそれらをエミュレーターにインストールしました (ここと同じ状況:このアプリは、 Google Play Services を更新します (Bazaar 経由) )。それらをインストールした後、ようやく MapFragment のインターフェースを実装することができました。

しかし、Android エミュレーター (OS 4.1.2; API 16) で実行すると、マップ内の何も機能しませんでした。「com.google.android.gsf.gservices のプロバイダー情報が見つかりませんでした」というエラーが出続けました。ワイヤレスプロバイダーと関係があるかどうかはわかりません。なぜそれが出続けたのか誰か知っていますか?どんな提案でも大歓迎です!

以前の質問のいくつかを説明すると、マップは正しく表示されました。しかし、マップ上のボタン (「+」と「-」) はまったく機能しませんでした。地図をクリックしたりドラッグしたりすることもできませんでした。ボタンをクリックしたり、地図をドラッグしたり、ダブルクリックしたりするたびに、応答がなく、LogCat に「com.google.android.gsf.gservices のプロバイダー情報が見つかりませんでした」というエラー メッセージが表示されました。

AndroidManifest.xml の私のコードは次のとおりです。

        <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.trackmyexercise"
        android:versionCode="1"
        android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="12"
        android:targetSdkVersion="17" />

    <permission
        android:name="com.example.trackmyexercise.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.example.trackmyexercise.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.trackmyexercise.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyANkR-VPI4zy5IpYGK2Z0T1omLq3C46rFE" />
    </application>

</manifest>

ここに私のレイアウトコードがあります:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/hello_world" />

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/recordsButton"
        android:layout_alignParentTop="true" />

</RelativeLayout>

そして、ここに私の MainActivity コードがあります:

    package com.example.trackmyexercise;

import android.os.Bundle;
import android.app.Activity;
import android.app.FragmentTransaction;
import android.view.Menu;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;

public class MainActivity extends Activity {
    GoogleMap myMap;
    MapFragment myMapFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_activity);

        myMapFragment = MapFragment.newInstance();
        FragmentTransaction fragmentTransaction = getFragmentManager()
                .beginTransaction();
        fragmentTransaction.add(R.id.map, myMapFragment);
        fragmentTransaction.commit();

        myMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))
                .getMap();
        this.setUpMapIfNeeded();
        myMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    private void setUpMapIfNeeded() {
        if (myMap == null) {
            myMap = ((MapFragment) getFragmentManager().findFragmentById(
                    R.id.map)).getMap();
        if (myMap != null) {
        }
    }
    }
}
4

2 に答える 2