简体   繁体   English

Activity.onCreate上的StackOverflowError

[英]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. (对于较大的屏幕设备,我们使用Theme.Dialog,对于其他屏幕设备,则使用常规。)继承的类仅覆盖onCreate来调用其super方法并设置一些窗口标志。

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. 我没有创建onCreateRegister所以我假设它是一个内部名称,但是我不确定。 I use ProGuard but the line numbers should be showing if the recursive calls are by my code. 我使用ProGuard,但如果递归调用是由我的代码执行的,则应显示行号。

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: StackOverflowError:

Thrown when the depth of the stack of the running program exceeds some platform or VM specific limit. 当正在运行的程序的堆栈深度超过某个平台或VM特定限制时抛出。 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. 但这可能是一个Android / Java错误,可能并不是您的错,或者您的某些递归操作无法正确执行。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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