1

我正在制作一个使用 google maps API 的 android 应用程序。我不断收到这些错误,不知道如何解决这个问题。我的实验室伙伴运行的代码与我正在运行的代码相同,但我的却给了我这些错误。任何帮助将不胜感激。

谢谢!以下是我得到的错误:

11-04 00:40:52.512: E/AndroidRuntime(328): FATAL EXCEPTION: main    
11-04 00:40:52.512: E/AndroidRuntime(328): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.googlemaps/com.example.googlemaps.MainActivity}: android.view.InflateException: Binary XML file line #17: Error inflating class fragment    
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)   
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)  
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)    
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.os.Handler.dispatchMessage(Handler.java:99)    
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.os.Looper.loop(Looper.java:123)    
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.app.ActivityThread.main(ActivityThread.java:3683)    
11-04 00:40:52.512: E/AndroidRuntime(328):  at java.lang.reflect.Method.invokeNative(Native Method)    
11-04 00:40:52.512: E/AndroidRuntime(328):  at java.lang.reflect.Method.invoke(Method.java:507)
11-04 00:40:52.512: E/AndroidRuntime(328):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-04 00:40:52.512: E/AndroidRuntime(328):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-04 00:40:52.512: E/AndroidRuntime(328):  at dalvik.system.NativeStart.main(Native Method)
11-04 00:40:52.512: E/AndroidRuntime(328): Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class fragment
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:587)
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-04 00:40:52.512: E/AndroidRuntime(328):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.app.Activity.setContentView(Activity.java:1657)
11-04 00:40:52.512: E/AndroidRuntime(328):  at com.example.googlemaps.MainActivity.onCreate(MainActivity.java:13)
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
11-04 00:40:52.512: E/AndroidRuntime(328):  ... 11 more   

11-04 00:40:52.512: E/AndroidRuntime(328): 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-04 00:40:52.512: E/AndroidRuntime(328):  at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)    
11-04 00:40:52.512: E/AndroidRuntime(328):  at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)    
11-04 00:40:52.512: E/AndroidRuntime(328):  at com.google.android.gms.maps.internal.q.v(Unknown Source)   
11-04 00:40:52.512: E/AndroidRuntime(328):  at com.google.android.gms.maps.internal.q.u(Unknown Source)   
11-04 00:40:52.512: E/AndroidRuntime(328):  at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)   
11-04 00:40:52.512: E/AndroidRuntime(328):  at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)   
11-04 00:40:52.512: E/AndroidRuntime(328):  at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)    
11-04 00:40:52.512: E/AndroidRuntime(328):  at com.google.android.gms.dynamic.a.a(Unknown Source)    
11-04 00:40:52.512: E/AndroidRuntime(328):  at com.google.android.gms.dynamic.a.onInflate(Unknown Source)    
11-04 00:40:52.512: E/AndroidRuntime(328):  at com.google.android.gms.maps.SupportMapFragment.onInflate(Unknown Source)    
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:284)    
11-04 00:40:52.512: E/AndroidRuntime(328):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
11-04 00:40:52.512: E/AndroidRuntime(328):  ... 20 more
4

3 回答 3

2

您必须将此添加到清单文件中的应用程序标记中:

 <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
于 2013-11-04T09:12:59.810 回答
0

从 sdk 工具中导入 gms 库,以便您使用最新版本的谷歌地图服务

不要忘记在清单文件中的应用程序中启动 gms 服务

 <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
于 2013-11-04T09:21:20.230 回答
0

我认为您需要在 Android 清单文件中添加您的 api 密钥:

<meta-data
            android:name="com.google.android.maps.v2.API_KEY"
             android:value="YOUR MAP API KEY HERE"/>
于 2013-11-04T09:18:01.463 回答