使用GoogleApiAvailability类的isGooglePlayServicesAvailable()方法会导致应用崩溃

时间:2017-02-10 07:15:13

标签: android

如果设备Google Play服务版本未更新,则在我的应用上使用以下代码会导致应用崩溃。

GoogleApiAvailability googleAPI = GoogleApiAvailability.getInstance();
status = googleAPI.isGooglePlayServicesAvailable(mActivity);

在Android操作系统版本4.2.2和Google Play服务版本3.1.58(我故意降级,以处理Google Play服务可用性检查)的设备上崩溃。

崩溃日志如下,

  

致命的例外:主要

     

java.lang.RuntimeException:无法启动活动   ComponentInfo {com.companyname / o.Dt}:   显示java.lang.NullPointerException                                                                           在   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2249)                                                                           在   android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)                                                                           在android.app.ActivityThread.access $ 700(ActivityThread.java:154)                                                                           在   android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1284)                                                                           在android.os.Handler.dispatchMessage(Handler.java:99)                                                                           在android.os.Looper.loop(Looper.java:137)                                                                           在android.app.ActivityThread.main(ActivityThread.java:5306)                                                                           at java.lang.reflect.Method.invokeNative(Native Method)                                                                           在java.lang.reflect.Method.invoke(Method.java:511)                                                                           在   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1102)                                                                           在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)                                                                           at dalvik.system.NativeStart.main(Native Method)                                                                        引起:java.lang.NullPointerException                                                                           at o.Lf。(:191)                                                                           at o.Lf.'(:237)                                                                           at o.Dt.onCreate(:487)                                                                           在android.app.Activity.performCreate(Activity.java:5255)                                                                           在   android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1097)                                                                           在   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2213)                                                                           在   android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2299)                                                                           在android.app.ActivityThread.access $ 700(ActivityThread.java:154)                                                                           在   android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1284)                                                                           在android.os.Handler.dispatchMessage(Handler.java:99)                                                                           在android.os.Looper.loop(Looper.java:137)                                                                           在android.app.ActivityThread.main(ActivityThread.java:5306)                                                                           at java.lang.reflect.Method.invokeNative(Native Method)                                                                           在java.lang.reflect.Method.invoke(Method.java:511)                                                                           在   com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1102)                                                                           在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)                                                                           在dalvik.system.NativeStart.main(本地方法)

NullPointer指向一些框架类,即使其名称被混淆了。所以,任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

可能错误不在您的代码中。按包名称,错误似乎来自公开的应用程序