在閱讀Google Play Services setup documentation時,聽起來Google Play Services for Froyo Rev. 12應該與Android 2.3及更高版本兼容。Google Play Services for Froyo是否與Android 2.3及更高版本兼容?
但是,我在我的GPSTest app on Github中執行此操作時遇到了問題,其中包括Google Play Services for Froyo。
如果我嘗試使用谷歌播放服務的Froyo版本12的元素構建一個項目:
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
...包含在AndroidManifest.xml中,我得到一個生成錯誤:
Error: No resource found that matches the given name (at 'value' with value '@integer/google_play_services_version').
由於Google Play Services for Froyo項目(sdk \ extras \ google \ google_play_services_froyo \ res \ values)中不存在此整數,因此這是預期的(根據我當前的理解)。
如果我從清單中刪除這個元素,它通過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)
我使用谷歌播放服務的Froyo版本12,和這裏的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>
有沒有一種方法,我可以部署單個APK到Google Play使用Google Play Services for Android 2.2及更高版本的Froyo Rev. 12?
如果我想保留對Froyo的支持,或者是否需要將兩個APK部署到Google Play(一個使用Google Play for Froyo for Android 2.2,另一個使用Google Play Services for Android 2.3或更高版本)?
有沒有人在Android 2.3及更高版本上成功部署Google Play Services for Froyo?
我假設你已經正確引用了庫。 「整數」應該存在於SDK文件夾中的「sdk \ extras \ google \ google_play_services \ libproject \ google-play-services_lib \ res \ values.xml」文件中。幾周前我遇到了類似的錯誤。我正在使用Android Studio。在我的gradle構建文件中,我指定了「compile」com.google.android.gms:play-services:4.0。+「。我所做的就是做一個「乾淨的」,然後我點擊「與Gradle文件同步項目」和中提琴!問題消失了。 – alpinescrambler
@alpinescrambler - 用於Google Play服務(Gingerbread +),而不是Google Play Services for Froyo(仍然是Google Play服務的3.2.65版)。 – ianhanniballake
Right,@alpinescrambler,在Google Play Services for Froyo包(sdk \ extras \ google \ google_play_services_froyo)中,該整數不存在。 –