1

そのため、メイン画面にボタンがあり、クリックするとユーザーが地図ビューに移動します。ただし、クリックするたびにアプリがクラッシュします。

4.1.1でGS3から実行しています

map_screen.xml:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

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

</RelativeLayout>

MapScreenActivity.java

package com.example.poopify;
import android.app.Activity;
import android.os.Bundle;

public class MapScreenActivity extends Activity  {

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


}

そして私のmanifest.xml

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

    <uses-sdk
        android:minSdkVersion="9"
        android:targetSdkVersion="14" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="com.example.poopify.permission.MAPS_RECEIVE"/>
    <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" >
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="AIzaSyBUIxDObzLKAfFrg04tPc78LBU1zkzZi6w" />
        <activity
            android:name="com.example.poopify.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>
        <activity android:name="com.example.poopify.MainScreen" >
        </activity>
        <activity
            android:name="com.example.poopify.MapScreenActivity"
            android:label="@string/title_activity_map_screen" >
        </activity>

    </application>



</manifest>

そして、私のlogcatをここに示しますが、それをどうするかはわかりません:

11-03 16:47:41.671: E/AndroidRuntime(18159): FATAL EXCEPTION: main
11-03 16:47:41.671: E/AndroidRuntime(18159): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.poopify/com.example.poopify.MapScreenActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.app.ActivityThread.access$700(ActivityThread.java:143)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.os.Looper.loop(Looper.java:137)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.app.ActivityThread.main(ActivityThread.java:4950)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at java.lang.reflect.Method.invokeNative(Native Method)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at java.lang.reflect.Method.invoke(Method.java:511)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at dalvik.system.NativeStart.main(Native Method)
11-03 16:47:41.671: E/AndroidRuntime(18159): Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class fragment
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:309)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.app.Activity.setContentView(Activity.java:1914)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at com.example.poopify.MapScreenActivity.onCreate(MapScreenActivity.java:13)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.app.Activity.performCreate(Activity.java:5179)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1094)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2074)
11-03 16:47:41.671: E/AndroidRuntime(18159):    ... 11 more
11-03 16:47:41.671: E/AndroidRuntime(18159): Caused by: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value.  Expected 4030500 but found 0.  You must have the following declaration within the <application> element:     <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
11-03 16:47:41.671: E/AndroidRuntime(18159):    at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at com.google.android.gms.maps.internal.q.v(Unknown Source)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at com.google.android.gms.maps.internal.q.u(Unknown Source)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at com.google.android.gms.maps.MapFragment$b.cE(Unknown Source)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at com.google.android.gms.maps.MapFragment$b.a(Unknown Source)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at com.google.android.gms.dynamic.a.a(Unknown Source)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at com.google.android.gms.dynamic.a.onInflate(Unknown Source)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.app.Activity.onCreateView(Activity.java:4829)
11-03 16:47:41.671: E/AndroidRuntime(18159):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
4

4 に答える 4

1

私の〜の上に...

次のような1行にする必要があります。

<meta-data android:value="XXX" android:name="com.google.android.gms.version"/>    

しかし、次のようになります。

<meta-data    
    android:name="com.google.android.maps.v2.API_KEY    
    android:value="API_KEY    

xmlで編集するだけでなく、この「Applicatin」タブを使用してこれを追加できると思います

于 2013-11-21T14:02:59.180 に答える