检查Google Play服务是否崩溃

时间:2016-04-06 15:36:37

标签: android libgdx google-play-services

我正在尝试检查Google Play服务是否是最新的。但我没有得到任何过时版本的对话框,之后会得到例外。

private boolean checkPlayServices() {
        GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
        int result = googleAPI.isGooglePlayServicesAvailable(this);
        if (result != ConnectionResult.SUCCESS) {
            if (googleAPI.isUserResolvableError(result)) {

                Dialog dialog = googleAPI.getErrorDialog(this, result, 9000);
                if (dialog != null) {
                    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface dialogInterface) {
                            Gdx.app.exit();
                        }
                    });
                    dialog.show();
                }

            } else {
                Log.i("googleServicesError", "This device is not supported.");
                finish();
            }
            return false;
        }
        return true;
    }

它可以正常使用更新的服务。但如果版本已经过时,它会崩溃。

04-06 18:27:47.530: E/dalvikvm(3511): Could not find class 'android.support.v4.util.ArrayMap', referenced from method com.google.android.gms.common.api.GoogleApiClient$Builder.zzoZ
04-06 18:27:47.530: W/dalvikvm(3511): VFY: unable to resolve new-instance 225 (Landroid/support/v4/util/ArrayMap;) in Lcom/google/android/gms/common/api/GoogleApiClient$Builder;
04-06 18:27:47.530: D/dalvikvm(3511): VFY: replacing opcode 0x22 at 0x000a
04-06 18:27:47.530: W/dalvikvm(3511): VFY: unable to find class referenced in signature (Landroid/support/v4/app/FragmentActivity;)
04-06 18:27:47.530: E/dalvikvm(3511): Could not find class 'android.support.v4.app.FragmentActivity', referenced from method com.google.android.gms.common.api.GoogleApiClient$Builder.enableAutoManage
04-06 18:27:47.530: W/dalvikvm(3511): VFY: unable to resolve check-cast 215 (Landroid/support/v4/app/FragmentActivity;) in Lcom/google/android/gms/common/api/GoogleApiClient$Builder;
04-06 18:27:47.530: D/dalvikvm(3511): VFY: replacing opcode 0x1f at 0x0010
04-06 18:27:47.530: W/dalvikvm(3511): VFY: unable to find class referenced in signature (Landroid/support/v4/app/FragmentActivity;)
04-06 18:27:47.530: W/dalvikvm(3511): VFY: unable to find class referenced in signature (Landroid/support/v4/app/FragmentActivity;)
04-06 18:27:47.530: D/dalvikvm(3511): DexOpt: unable to opt direct call 0x0439 at 0x13 in Lcom/google/android/gms/common/api/GoogleApiClient$Builder;.<init>
04-06 18:27:47.530: D/dalvikvm(3511): DexOpt: unable to opt direct call 0x0439 at 0x1a in Lcom/google/android/gms/common/api/GoogleApiClient$Builder;.<init>
04-06 18:27:47.530: D/dalvikvm(3511): DexOpt: unable to opt direct call 0x0439 at 0x0c in Lcom/google/android/gms/common/api/GoogleApiClient$Builder;.zzoZ
04-06 18:27:47.530: D/dalvikvm(3511): DexOpt: unable to opt direct call 0x0439 at 0x11 in Lcom/google/android/gms/common/api/GoogleApiClient$Builder;.zzoZ
04-06 18:27:47.530: W/GooglePlayServicesUtil(3511): Google Play services out of date.  Requires 8487000 but found 5089070
04-06 18:27:51.410: W/GAv4(3511): syncDispatchLocalHits timed out: java.util.concurrent.TimeoutException
04-06 18:27:51.420: E/AndroidRuntime(3511): FATAL EXCEPTION: main
04-06 18:27:51.420: E/AndroidRuntime(3511): Process: com.mygdx.one4all, PID: 3511
04-06 18:27:51.420: E/AndroidRuntime(3511): java.lang.NoClassDefFoundError: android.support.v4.util.SimpleArrayMap
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.google.android.gms.ads.internal.zzs.<init>(Unknown Source)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.google.android.gms.ads.internal.zzs.<init>(Unknown Source)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.google.android.gms.ads.internal.zzb.<init>(Unknown Source)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.google.android.gms.ads.internal.zzc.<init>(Unknown Source)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.google.android.gms.ads.internal.zzk.<init>(Unknown Source)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.google.android.gms.ads.internal.ClientApi.createInterstitialAdManager(Unknown Source)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.google.android.gms.ads.internal.client.zzl.createInterstitialAdManager(Unknown Source)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.google.android.gms.ads.internal.client.zze.zzb(Unknown Source)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.google.android.gms.ads.internal.client.zzac.zzH(Unknown Source)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.google.android.gms.ads.internal.client.zzac.zza(Unknown Source)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.google.android.gms.ads.InterstitialAd.loadAd(Unknown Source)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.mygdx.one4all.AndroidLauncher.setupAds(AndroidLauncher.java:103)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.mygdx.one4all.AndroidLauncher.onCreate(AndroidLauncher.java:81)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at android.app.Activity.performCreate(Activity.java:5411)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2396)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at android.app.ActivityThread.access$800(ActivityThread.java:139)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1293)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at android.os.Handler.dispatchMessage(Handler.java:102)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at android.os.Looper.loop(Looper.java:149)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at android.app.ActivityThread.main(ActivityThread.java:5257)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at java.lang.reflect.Method.invokeNative(Native Method)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at java.lang.reflect.Method.invoke(Method.java:515)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:610)
04-06 18:27:51.420: E/AndroidRuntime(3511):     at dalvik.system.NativeStart.main(Native Method)
04-06 18:27:52.590: E/GAv4(3511): Successfully bound to service but never got onServiceConnected callback

我该怎么办?

1 个答案:

答案 0 :(得分:0)

将android-support-v4.jar添加到yourProject-android-libs。