我在 2.1 版手机上运行它。当我调试它时,我发现函数 GooglePlayServicesUtil.isGooglePlayServicesAvailable() 崩溃了。
据说“找不到方法 android.util.Base64.decode”。2.1版本太低了?还是手机需要安装google play服务?
这是代码:
int status=GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());
if (status!=ConnectionResult.SUCCESS)
{
...
}
这是日志猫:
07-23 21:56:40.194: D/dalvikvm(5109): GC freed 841 objects / 63592 bytes in 33ms
07-23 21:56:42.304: D/dalvikvm(5109): GC freed 534 objects / 29576 bytes in 34ms
07-23 21:56:43.244: I/dalvikvm(5109): Could not find method android.util.Base64.decode, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.<clinit>
07-23 21:56:43.244: W/dalvikvm(5109): VFY: unable to resolve static method 3190: Landroid/util/Base64;.decode (Ljava/lang/String;I)[B
07-23 21:56:43.244: D/dalvikvm(5109): VFY: replacing opcode 0x71 at 0x0007
07-23 21:56:43.244: D/dalvikvm(5109): Making a copy of Lcom/google/android/gms/common/GooglePlayServicesUtil;.<clinit> code (208 bytes)
07-23 21:56:43.249: I/dalvikvm(5109): Could not find method android.util.Base64.encodeToString, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.a
07-23 21:56:43.254: W/dalvikvm(5109): VFY: unable to resolve static method 3191: Landroid/util/Base64;.encodeToString ([BI)Ljava/lang/String;
07-23 21:56:43.254: D/dalvikvm(5109): VFY: replacing opcode 0x71 at 0x0084
07-23 21:56:43.254: D/dalvikvm(5109): Making a copy of Lcom/google/android/gms/common/GooglePlayServicesUtil;.a code (356 bytes)
07-23 21:56:43.254: D/dalvikvm(5109): DexOpt: couldn't find field Landroid/content/res/Configuration;.smallestScreenWidthDp
07-23 21:56:43.254: W/dalvikvm(5109): VFY: unable to resolve instance field 24
07-23 21:56:43.254: D/dalvikvm(5109): VFY: replacing opcode 0x52 at 0x0012
07-23 21:56:43.254: D/dalvikvm(5109): Making a copy of Lcom/google/android/gms/common/GooglePlayServicesUtil;.b code (68 bytes)
07-23 21:56:43.254: I/dalvikvm(5109): Could not find method android.util.Log.wtf, referenced from method com.google.android.gms.common.GooglePlayServicesUtil.isGooglePlayServicesAvailable
07-23 21:56:43.254: W/dalvikvm(5109): VFY: unable to resolve static method 3202: Landroid/util/Log;.wtf (Ljava/lang/String;Ljava/lang/String;)I
07-23 21:56:43.254: D/dalvikvm(5109): VFY: replacing opcode 0x71 at 0x0083
07-23 21:56:43.254: D/dalvikvm(5109): Making a copy of Lcom/google/android/gms/common/GooglePlayServicesUtil;.isGooglePlayServicesAvailable code (334 bytes)
07-23 21:56:43.259: W/dalvikvm(5109): Exception Ljava/lang/NoClassDefFoundError; thrown during Lcom/google/android/gms/common/GooglePlayServicesUtil;.<clinit>
07-23 21:56:43.259: D/AndroidRuntime(5109): Shutting down VM
07-23 21:56:43.259: W/dalvikvm(5109): threadid=3: thread exiting with uncaught exception (group=0x4001dc20)
07-23 21:56:43.259: E/AndroidRuntime(5109): Uncaught handler: thread main exiting due to uncaught exception
07-23 21:56:43.269: E/AndroidRuntime(5109): java.lang.ExceptionInInitializerError
07-23 21:56:43.269: E/AndroidRuntime(5109): at com.wswsoft.porsche.AssistFm.checkGoogleService(AssistFm.java:222)
07-23 21:56:43.269: E/AndroidRuntime(5109): at com.wswsoft.porsche.AssistFm.onClick(AssistFm.java:81)
07-23 21:56:43.269: E/AndroidRuntime(5109): at android.view.View.performClick(View.java:2417)
07-23 21:56:43.269: E/AndroidRuntime(5109): at android.view.View.onTouchEvent(View.java:4232)
07-23 21:56:43.269: E/AndroidRuntime(5109): at android.widget.TextView.onTouchEvent(TextView.java:6559)
07-23 21:56:43.269: E/AndroidRuntime(5109): at android.view.View.dispatchTouchEvent(View.java:3762)
07-23 21:56:43.269: E/AndroidRuntime(5109): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-23 21:56:43.269: E/AndroidRuntime(5109): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-23 21:56:43.269: E/AndroidRuntime(5109): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:884)
07-23 21:56:43.269: E/AndroidRuntime(5109): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1713)
07-23 21:56:43.269: E/AndroidRuntime(5109): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1131)
07-23 21:56:43.269: E/AndroidRuntime(5109): at android.app.Activity.dispatchTouchEvent(Activity.java:2070)
07-23 21:56:43.269: E/AndroidRuntime(5109): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1697)
07-23 21:56:43.269: E/AndroidRuntime(5109): at android.view.ViewRoot.handleMessage(ViewRoot.java:1691)
07-23 21:56:43.269: E/AndroidRuntime(5109): at android.os.Handler.dispatchMessage(Handler.java:99)
07-23 21:56:43.269: E/AndroidRuntime(5109): at android.os.Looper.loop(Looper.java:123)
07-23 21:56:43.269: E/AndroidRuntime(5109): at android.app.ActivityThread.main(ActivityThread.java:4363)
07-23 21:56:43.269: E/AndroidRuntime(5109): at java.lang.reflect.Method.invokeNative(Native Method)
07-23 21:56:43.269: E/AndroidRuntime(5109): at java.lang.reflect.Method.invoke(Method.java:521)
07-23 21:56:43.269: E/AndroidRuntime(5109): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:862)
07-23 21:56:43.269: E/AndroidRuntime(5109): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
07-23 21:56:43.269: E/AndroidRuntime(5109): at dalvik.system.NativeStart.main(Native Method)
07-23 21:56:43.269: E/AndroidRuntime(5109): Caused by: java.lang.NoClassDefFoundError: android.util.Base64
07-23 21:56:43.269: E/AndroidRuntime(5109): at com.google.android.gms.common.GooglePlayServicesUtil.<clinit>(Unknown Source)
07-23 21:56:43.269: E/AndroidRuntime(5109): ... 22 more