简体   繁体   中英

StackOverflowError on Activity.onCreate

I have two activities with same name on two different packages. One is just a subclass of another. I do this to use two different themes, depending on devices. (We use Theme.Dialog for larger screen device, and regular for others.) The inherited class only overrides onCreate to call its super method and set some window flags.

This works very well on all my devices, but I get very weird crash reports a few time.

java.lang.StackOverflowError
    at *****.activities.Register.onCreate(SourceFile)
    at *****.tablet.Register.onCreateRegister(SourceFile)
    (a lot of repeats)
    at *****.activities.Register.onCreate(SourceFile)
    at *****.tablet.Register.onCreateRegister(SourceFile)
    at *****.activities.Register.onCreate(SourceFile)
    at *****.tablet.Register.onCreateRegister(SourceFile)
    at *****.tablet.Register.onCreate(SourceFile)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3683)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:850)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:608)
    at dalvik.system.NativeStart.main(Native Method)

I did not create onCreateRegister so I assume it's an internal name, but I am not sure. I use ProGuard but the line numbers should be showing if the recursive calls are by my code.

I can't replicate it in any of my devices, and I get this report even from the same model I already test on, so it's probably not a device-specific problem.

Does anybody have any idea why this is happening, or have a better way to handle this?

StackOverflowError:

Thrown when the depth of the stack of the running program exceeds some platform or VM specific limit. Typically, this will occur only when a program becomes infinitely recursive, but it can also occur in correctly written (but deeply recursive) programs.

Don't know where to tell you to go with that information, because I haven't seen your code. But it would be an Android/Java error that may not really be your fault, or you may have something that's recursive which you fail to execute properly.

我重命名了我的班级,所以父班级和子班级不再具有相同的名称,这似乎已经解决了问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM