Java 使用 Google Maps API “除非您更新 Google Play 服务,否则应用程序不会运行”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19733649/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
“App won't run unless you update Google Play services” with Google Maps API
提问by Sekhmet
I created an app with Google Maps API. After few hours of trying to resolve errors, I successfuly runned it(without crashes). But now I get a error.
我使用 Google Maps API 创建了一个应用程序。经过几个小时的尝试解决错误后,我成功运行了它(没有崩溃)。但现在我得到一个错误。
That alert means “App won't run unless you update Google Play services”. I heard about that error with emulator, but I'm using real device(LG P350 on Gingerbread). I have got device with android 2.3 so I use SupportLibrary.
该警报表示“除非您更新 Google Play 服务,否则应用程序不会运行”。我听说过模拟器的错误,但我使用的是真实设备(姜饼上的 LG P350)。我有 android 2.3 的设备,所以我使用 SupportLibrary。
My activity file
我的活动档案
<?xml version="1.0" encoding="utf-8"?>
<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"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".Map" >
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
And AndroidManifest
和 AndroidManifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.secrop.where360"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<permission
android:name="io.secorp.where360.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="io.secorp.where360.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<!-- The following two permissions are not required to use
Google Maps Android API v2, but are recommended. -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<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="MY_API_KEY"/>
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
<activity
android:name="io.secrop.where360.Map"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Any ideas?
有任何想法吗?
采纳答案by MaciejGórski
You have hit a wrong point in time.
你打错了时间点。
Google Play Services have been updated to 4.0.30 very recently and so you seem to be using that version of google-play-services_lib. Assumption based on this line:
Google Play 服务最近已更新到 4.0.30,因此您似乎正在使用该版本的 google-play-services_lib。基于这一行的假设:
<meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
Not all devices have received an update of GooglePlayServices.APK, which needs to be at least the same version as a client library you are using.
并非所有设备都收到了 GooglePlayServices.APK 的更新,它至少需要与您使用的客户端库版本相同。
Check version of GPServices.APK in Settings app. For me it is still at 3.2.66 and last time I had to wait few days for the update.
在“设置”应用中检查 GPServices.APK 的版本。对我来说,它仍然是 3.2.66,上次我不得不等待几天才能更新。
If you are using gradle, you can put lower version dependency. If not, you have to download older version of google-play-services_lib from somewhere.
如果您使用的是 gradle,则可以放置较低版本的依赖项。如果没有,您必须从某个地方下载旧版本的 google-play-services_lib。
Edit:
编辑:
or get Google Play Services for Froyo from Android SDK. It is the same as previous release (3.2.65).
或从 Android SDK 获取 Froyo 的 Google Play 服务。它与之前的版本 (3.2.65) 相同。