应用程序崩溃在特定的Android版本上

时间:2015-06-23 05:20:59

标签: android crash

我正在开发Android应用程序。当我在api 16下面运行我的应用程序时它工作正常但是当它在后api 16手机上运行时它会崩溃。这是崩溃时出现的logact日志。

06-19 20:20:05.096    5812-5812/com.ets.medecord W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x42011898)
06-19 20:20:05.106    5812-5812/com.ets.medecord E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ets.medecord/com.ets.medecord.SignupActivity2}: java.lang.NullPointerException
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2218)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2268)
            at android.app.ActivityThread.access$600(ActivityThread.java:148)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1263)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5162)
            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:756)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:572)
            at miui.dexspy.DexspyInstaller.main(DexspyInstaller.java:171)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NullPointerException
            at com.ets.medecord.SignupActivity2.onCreate(SignupActivity2.java:72)
            at android.app.Activity.performCreate(Activity.java:5135)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at com.lbe.security.service.core.client.b.x.callActivityOnCreate(Unknown Source)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2182)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2268)
            at android.app.ActivityThread.access$600(ActivityThread.java:148)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1263)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5162)
            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:756)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:572)
            at miui.dexspy.DexspyInstaller.main(DexspyInstaller.java:171)
            at dalvik.system.NativeStart.main(Native Method)

要查看活动代码,您可以查看此要点https://gist.github.com/darthvish/873dc292c841e5c86312

1 个答案:

答案 0 :(得分:0)

由于您使用的是某些已弃用的功能,因此某些API级别可能不支持此功能。为此,您可以在使用if条件使用不推荐使用的功能之前检查api级别和版本。例如:

if(Build.VERSION.RELEASE.equals("4.4.4")) {
            //Do somthing
}