2013-11-03 184 views
1

所以我在主屏幕上有一個按鈕,點擊後會將用戶帶到地圖視圖。但是,每次點擊它,應用程序崩潰。Google Maps V2 bug

我從我的GS3 4.1.1

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 b UT IDK的,使這是什麼:

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) 
+0

的可能重複[之後Google Play服務更新至版本13我收到錯誤](http://stackoverflow.com/questions/19723811/after-google-play-service-update-to-version-13-i-got-an-error) – CommonsWare

回答

1

如果實際讀取錯誤你會看到你缺少你minifest東西。

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

隨着谷歌播放服務4.0,你需要聲明你的清單中有什麼版本的谷歌播放服務。

因此,它是不是一個錯誤

+0

它的工作對我感謝bro –

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

0

我更新後有同樣的問題。我沒有找到崩潰的來源,看完日誌貓後,我只是增加了這一行:

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

而且,它的工作就像一個魅力。

希望這將有助於休假一天;)

+0

我還添加了這個元數據,它的工作!謝謝! – John

+0

快樂,可以幫助你。不要忘記爲我的答案upvote;) –

2

它的工作對我來說也..所有你需要做的是有以下兩個元數據標籤鏈接:

<meta-data 
       android:name="com.google.android.maps.v2.API_KEY" 
       android:value="yourGoogleAPIKeyHere" /> 
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> 
相關問題