谷歌地图不起作用

时间:2013-12-18 14:17:01

标签: android google-maps

我想在片段中显示一个地图,如果用户选择一个选项卡,则该片段可见,此选项卡包含在MainActivity中包含的另一个片段中。显示地图的片段从SupportMapFragment扩展。

我按照Android开发人员提供的说明进行操作,最初工作正常。由于android版本不兼容引起的一些变化:actionBar,viewPager ...我退出了库并重新链接它(以两种方式:首先从库项目中执行链接,因为它不起作用,删除库项目并重新导入它并将库添加到我的项目中。希望这个解释可以理解,不要弄乱它。)

第一个log-cat让我将清单的元数据更改为

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

我这样做了并重复了错误:

12-18 08:36:27.589: E/AndroidRuntime(1613): FATAL EXCEPTION: main
12-18 08:36:27.589: E/AndroidRuntime(1613): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.comercio/com.comercio.activities.MainActivity}: 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" />
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.os.Looper.loop(Looper.java:137)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.app.ActivityThread.main(ActivityThread.java:5103)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at java.lang.reflect.Method.invokeNative(Native Method)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at java.lang.reflect.Method.invoke(Method.java:525)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at dalvik.system.NativeStart.main(Native Method)
12-18 08:36:27.589: E/AndroidRuntime(1613): 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" />
12-18 08:36:27.589: E/AndroidRuntime(1613):     at com.google.android.gms.common.GooglePlayServicesUtil.n(Unknown Source)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable(Unknown Source)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at com.google.android.gms.maps.internal.q.v(Unknown Source)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at com.google.android.gms.maps.internal.q.u(Unknown Source)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at com.google.android.gms.maps.MapsInitializer.initialize(Unknown Source)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at com.google.android.gms.maps.SupportMapFragment$b.cE(Unknown Source)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at com.google.android.gms.maps.SupportMapFragment$b.a(Unknown Source)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at com.google.android.gms.dynamic.a.a(Unknown Source)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at com.google.android.gms.dynamic.a.onCreate(Unknown Source)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at com.google.android.gms.maps.SupportMapFragment.onCreate(Unknown Source)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.support.v4.app.Fragment.performCreate(Fragment.java:1477)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:893)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1467)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:570)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1171)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.app.Activity.performStart(Activity.java:5143)
12-18 08:36:27.589: E/AndroidRuntime(1613):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2184)
12-18 08:36:27.589: E/AndroidRuntime(1613):     ... 11 more

清单

<meta-data
       android:name="com.google.android.gsm.version"
        android:value="@integer/google_play_services_version" />
<permission
    android:name="com.comercio.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

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

我在这里和所有地方寻找答案,但找不到解决方法。

感谢您的帮助

1 个答案:

答案 0 :(得分:0)

你有gsm错误的gms。它应该是这样的:

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