0

Google Maps API v2 で SupportMapFragment クラスを使用しようとしています。しかし、私はこのエラーに遭遇し続けます。google-play-services_lib プロジェクトをインポートし、Java ビルド パスに追加しました。

    03-29 23:58:09.893: E/AndroidRuntime(26163): FATAL EXCEPTION: main
    03-29 23:58:09.893: E/AndroidRuntime(26163): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.yo/com.example.yo.MainActivity}: android.view.InflateException: Binary XML file line #13: Error inflating class fragment
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1830)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1851)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.app.ActivityThread.access$1500(ActivityThread.java:132)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.os.Handler.dispatchMessage(Handler.java:99)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.os.Looper.loop(Looper.java:150)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.app.ActivityThread.main(ActivityThread.java:4277)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at java.lang.reflect.Method.invokeNative(Native Method)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at java.lang.reflect.Method.invoke(Method.java:507)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at dalvik.system.NativeStart.main(Native Method)
    03-29 23:58:09.893: E/AndroidRuntime(26163): Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class fragment
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:250)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.app.Activity.setContentView(Activity.java:1712)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at com.example.yo.MainActivity.onCreate(MainActivity.java:11)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1794)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    ... 11 more
    03-29 23:58:09.893: E/AndroidRuntime(26163): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f060000
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.content.res.Resources.getValue(Resources.java:901)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.content.res.Resources.openRawResource(Resources.java:826)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.content.res.Resources.openRawResource(Resources.java:808)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at maps.af.w.a(Unknown Source)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at maps.z.ab.a(Unknown Source)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at maps.z.ag.a(Unknown Source)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at maps.z.ag.a(Unknown Source)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at maps.z.bw.a(Unknown Source)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at maps.z.r.onCreateView(Unknown Source)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at com.google.android.gms.maps.internal.IMapFragmentDelegate$Stub.onTransact(IMapFragmentDelegate.java:107)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.os.Binder.transact(Binder.java:279)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at com.google.android.gms.maps.internal.IMapFragmentDelegate$a$a.onCreateView(Unknown Source)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at com.google.android.gms.maps.SupportMapFragment$a.onCreateView(Unknown Source)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at com.google.android.gms.internal.e$4.a(Unknown Source)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at com.google.android.gms.internal.e.a(Unknown Source)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at com.google.android.gms.internal.e.onCreateView(Unknown Source)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at com.google.android.gms.maps.SupportMapFragment.onCreateView(Unknown Source)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.support.v4.app.Fragment.performCreateView(Fragment.java:1460)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:884)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1066)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1168)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:280)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
    03-29 23:58:09.893: E/AndroidRuntime(26163):    ... 20 more
    03-29 23:58:09.933: D/dalvikvm(26163): GC_CONCURRENT freed 367K, 45% free 3282K/5959K, external 0K/0K, paused 6ms+5ms
    03-29 23:58:11.764: I/Process(26163): Sending signal. PID: 26163 SIG: 9

これが私のマニフェストです:

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

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

        <uses-permission
            android:name="com.example.yo.permission.MAPS_RECEIVE"/>
        <uses-permission
            android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
        <uses-permission
            android:name="android.permission.INTERNET"/>
        <uses-permission
            android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 
        <uses-feature
            android:glEsVersion="0x00020000"
            android:required="true"/> 

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

        <application
            android:allowBackup="true"
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name="com.example.yo.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>
            <uses-library android:name="com.google.android.maps" />
             <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="the key"/>
        </application>
    </manifest>

私のメインアクティビティ:

    package com.example.yo;

    import android.os.Bundle;
    import android.support.v4.app.FragmentActivity;

    public class MainActivity extends FragmentActivity {

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

そしてXML:

    <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"
        tools:context=".MainActivity" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:text="@string/hello_world" />
        <fragment
            android:id="@+id/map"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            class="com.google.android.gms.maps.SupportMapFragment"/>

    </RelativeLayout>

ここで何が欠けていますか?

4

1 に答える 1

1

次のコード行をマニファスト ファイルから削除します。

 <uses-library android:name="com.google.android.maps" />

Google マップ API V2 では必要ありません。

現在の問題とは関係ありませんが、次の権限も追加する必要があります。

<uses-permission android:name="android.permission.INTERNET" />
<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" />

他の方法で Google ライブラリを追加する必要があります。詳細については、私が書いたブログ投稿を参照してください。

Google マップ API V2

于 2013-03-29T18:43:56.697 に答える