0

Android アプリケーションで Google マップを表示したいと考えています。google api で試してみたのですが、API 12 以下で問題があるようです。だから私はこのページ(http://www.truiton.com/2013/05/android-supportmapfragment-example/)の例を使用しましたが、私のAPI 7デバイス(xperia 10 mini pro)ではうまくいかないようです. そのページで同じコードを使用しましたが、アプリケーションの起動後に次のエラーが発生します。

10-18 18:04:55.481: E/AndroidRuntime(3980): Uncaught handler: thread main exiting due to uncaught exception
10-18 18:04:55.491: E/AndroidRuntime(3980): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.maps/com.example.maps.MainActivity}: java.lang.ClassNotFoundException: com.example.maps.MainActivity in loader dalvik.system.PathClassLoader@458fc8e0

「Android ツール」メニューの「サポート ライブラリの追加」を行ってもこのエラーが発生しますが、機能しません。Web ビューで GM を使用するのは良い考えではないことがわかったので、この問題を解決したいと思いました。

4

2 に答える 2

1

Google マップ v2 を使用するには、2.2 (API 8) 以降を使用する必要があります

于 2013-10-18T17:45:57.260 に答える
0

こちらを参照してください。API キーをマニフェスト ファイルのキーで変更し、次の手順に従ってください: google_play_services_lib プロジェクトがプロジェクトのワークスペースにのみ存在することを確認してください。

マニフェスト ファイル:

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

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

    <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" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.geeklabs.map.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="replace with your API key"/>

    </application>

</manifest>

MainActivity.java:

    package com.geeklabs.map;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

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

}

activity_main.xml:

    <?xml version="1.0" encoding="utf-8"?>
    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/map"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:name="com.google.android.gms.maps.MapFragment"/>

これを受け取った後、私に知らせてください。

于 2013-10-21T10:24:11.450 に答える