eclipse 适用于 Froyo 的 Google Play 服务是否与 Android 2.3 及更高版本兼容?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20534090/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:23:12  来源:igfitidea点击:

Is Google Play Services for Froyo compatible with Android 2.3 and higher?

androideclipsegoogle-play-services

提问by Sean Barbeau

In reading the Google Play Services setup documentation, it sounds like Google Play Services for Froyo Rev. 12 should be forwards-compatible with Android 2.3 and above.

在阅读Google Play 服务设置文档 时,听起来 Froyo Rev. 12 的 Google Play 服务应该向前兼容 Android 2.3 及更高版本。

However, I'm having issues implementing this in my GPSTest app on Github, which currently includes Google Play Services for Froyo.

但是,我在 Github 上的 GPSTest 应用程序中实现此功能时遇到问题,该应用程序目前包括 Froyo 的 Google Play 服务。

If I try to build a project using Google Play Services for Froyo Rev. 12 with the element:

如果我尝试使用 Google Play Services for Froyo Rev. 12 和元素构建一个项目:

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

...included in the AndroidManifest.xml, I get a build error:

...包含在 AndroidManifest.xml 中,我收到一个构建错误:

Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').

This is expected (from my current understanding) because this integer doesn't exist in the Google Play Services for Froyo project (sdk\extras\google\google_play_services_froyo\res\values).

这是预期的(根据我目前的理解),因为这个整数在 Google Play Services for Froyo 项目 (sdk\extras\google\google_play_services_froyo\res\values) 中不存在。

If I remove this element from the manifest, it works fine when building and debugging the app via Eclipse (as I would expect). However, when I export the APK, install on a device (Samsung Galaxy S3 Android 4.3, Google Play Services v4.0.34 - downloading the exported APK from Dropbox), and run, I get the following error on startup, and the app crashes:

如果我从清单中删除这个元素,它在通过 Eclipse 构建和调试应用程序时工作正常(正如我所期望的)。但是,当我导出 APK,在设备上安装(Samsung Galaxy S3 Android 4.3,Google Play Services v4.0.34 - 从 Dropbox 下载导出的 APK)并运行时,我在启动时收到以下错误,并且应用程序崩溃:

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" />
        at com.google.android.gms.common.b.a(Unknown Source)
        at com.google.android.gms.maps.a.bn.a(Unknown Source)
        at com.google.android.gms.maps.m.g(Unknown Source)
        at com.google.android.gms.maps.m.a(Unknown Source)
        at com.google.android.gms.a.b.a(Unknown Source)
        at com.google.android.gms.a.b.a(Unknown Source)
        at com.google.android.gms.maps.SupportMapFragment.onCreate(Unknown Source)
        at android.support.v4.app.Fragment.performCreate(Unknown Source)
        at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source)
        at android.support.v4.app.FragmentManagerImpl.moveToState(Unknown Source)
        at android.support.v4.app.BackStackRecord.run(Unknown Source)
        at android.support.v4.app.FragmentManagerImpl.execPendingActions(Unknown Source)
        at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(Unknown Source)
        at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(Unknown Source)
        at android.support.v4.view.ViewPager.populate(Unknown Source)
        at android.support.v4.view.ViewPager.populate(Unknown Source)
        at android.support.v4.view.ViewPager.onMeasure(Unknown Source)
        at android.view.View.measure(View.java:16848)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5245)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
        at android.view.View.measure(View.java:16848)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5245)
        at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:302)
        at android.view.View.measure(View.java:16848)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5245)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2586)
        at android.view.View.measure(View.java:16848)
        at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2189)
        at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1352)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1535)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1249)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6364)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:791)
        at android.view.Choreographer.doCallbacks(Choreographer.java:591)
        at android.view.Choreographer.doFrame(Choreographer.java:561)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:777)
        at android.os.Handler.handleCallback(Handler.java:730)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5455)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:525)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
        at dalvik.system.NativeStart.main(Native Method)

I'm using Google Play Services for Froyo Rev. 12, and here's the AndroidManifest.xml with the full version info:

我正在为 Froyo Rev. 12 使用 Google Play 服务,这里是带有完整版本信息的 AndroidManifest.xml:

<manifest android:versionName="3.2.65 (834000-30)" android:versionCode="3265130" 
    package="com.google.android.gms" 
    xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-sdk android:minSdkVersion="8"/>  </manifest>

Is there a way I can deploy a single APK to Google Play using Google Play Services for Froyo Rev. 12 for Android 2.2 and higher?

有什么方法可以使用适用于 Android 2.2 及更高版本的 Froyo Rev. 12 的 Google Play 服务将单个 APK 部署到 Google Play?

Or do I need to deploy two APKs to Google Play (one using Google Play Services for Froyo for Android 2.2, and one using Google Play Services for Android 2.3 and up) if I want to retain support for Froyo?

或者,如果我想保留对 Froyo 的支持,我是否需要将两个 APK 部署到 Google Play(一个使用适用于 Android 2.2 的 Froyo 的 Google Play 服务,一个使用适用于 Android 2.3 及更高版本的 Google Play 服务)?

Has anyone successfully deployed Google Play Services for Froyo on Android 2.3 and up?

有没有人在 Android 2.3 及更高版本上成功部署了 Froyo 的 Google Play 服务?

采纳答案by Sean Barbeau

The answer is yes, Google Play Services for Froyo is forwards compatible with Android 2.3 and higher, and the manifest element isn't needed.

答案是肯定的,Froyo 的 Google Play 服务向前兼容 Android 2.3 及更高版本,并且不需要 manifest 元素。

Looks like this issue was actually a bug in the Google Maps app.

看起来这个问题实际上是谷歌地图应用程序中的一个错误。

A Maps app update started rolling out yesterday (12/12/2013), and my phone installed it today (new version is v7.5.0). After this, the crashing problem on startup magically disappeared. I even went back and tested an old version of the APK from Dropbox that was definitely crashing (just in case my other changes in Eclipse fixed something), and that now works as well.

昨天(12/12/2013)开始推出地图应用更新,我的手机今天安装了它(新版本是 v7.5.0)。之后,启动时的崩溃问题神奇地消失了。我什至回去测试了一个来自 Dropbox 的旧版 APK,它肯定会崩溃(以防万一我在 Eclipse 中的其他更改修复了某些问题),现在也可以正常工作。

(Note that you should only be using Google Play Services for Froyo if you're supporting API level 8 - Android 2.2. If your minSdkVersionis >= 9, then you should be using the most recent version of Google Play Services, as no new features are being added to Google Play Services for Froyo.)

(请注意,如果您支持 API 级别 8 - Android 2.2,您应该只为 Froyo 使用 Google Play 服务。如果您的级别minSdkVersion>= 9,那么您应该使用最新版本的 Google Play 服务,因为没有新功能正在添加到 Froyo 的 Google Play 服务中。)

回答by gian1200

You dont need

你不需要

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

That is for the Up-to-date Google Play Services revision. If you use the "Google Play Services for Froyo" library, then you don't need it.

这是针对最新的 Google Play 服务修订版。如果您使用“Google Play Services for Froyo”库,则不需要它。

Now, talking about the other problem. How exactly are you "debugging the app via Eclipse"? Are you using the debug key or your release key? how are you installing the APK inside the device? have you tried to do a uninstall->install? Did you use the ADB install or you uploaded the APK as an Alpha/Beta test? Are you sure that you are installing the right APK?

现在,谈论另一个问题。你究竟是如何“通过 Eclipse 调试应用程序”的?您使用的是调试密钥还是发布密钥?你是如何在设备内安装APK的?您是否尝试过卸载-> 安装?您是使用 ADB 安装还是上传了 APK 作为 Alpha/Beta 测试?您确定要安装正确的 APK?

回答by whizzzkey

It is a weird bug, I solved this problem by this way - just changed android:value="@integer/google_play_services_version" to 3265130.

这是一个奇怪的错误,我通过这种方式解决了这个问题 - 只是将 android:value="@integer/google_play_services_version" 更改为 3265130。

回答by alex

enter image description here

在此处输入图片说明

Create an integer resource seems to solve the problem.

创建一个整数资源似乎可以解决问题。

But I ended up bumping into each other.

但我最终撞到了对方。

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

There is no package "ads.AdActivity". Even adding the froyo version:

没有包“ ads.AdActivity”。甚至添加 froyo 版本:

compile 'com.google.android.gms:play-services:3.2.65'

compile 'com.google.android.gms:play-services:3.2.65'

The documentation says nothing about the froyo version:

该文档没有说明 froyo 版本:

https://developers.google.com/mobile-ads-sdk/docs/

https://developers.google.com/mobile-ads-sdk/docs/

回答by zelanix

For me, the java.lang.IllegalStateExceptionseemed to occur because I had previously linked to the full Google Play services (version 22) before changing to Google Play services for Froyo. There must have been some remnant of version 22 left in the build and doing a full clean and rebuild fixed the problem.

对我来说,这java.lang.IllegalStateException似乎是因为我之前已链接到完整的 Google Play 服务(版本 22),然后才更改为 Froyo 的 Google Play 服务。构建中肯定有版本 22 的一些残余,并且进行了完全清理和重建修复了问题。