2011-12-23 31 views
0

我在两个不同的包上有两个具有相同名称的活动。一个只是另一个的子类。我这样做是根据设备使用两个不同的主题。 (我们将Theme.Dialog用于较大的屏幕设备,对其他设备使用Theme.Dialog。)继承类仅覆盖onCreate以调用其超级方法并设置一些窗口标志。Activity.onCreate上的StackOverflowError

这在我的所有设备上都能很好地工作,但是我几次得到非常奇怪的故障报告。

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) 

我没有创建onCreateRegister,所以我认为它是一个内部的名字,但我不知道。我使用ProGuard,但是如果递归调用是由我的代码显示的,行号应该显示。

我无法在任何设备上复制它,甚至可以从我已经测试过的同一型号中获得此报告,因此它可能不是设备特定的问题。

有没有人知道为什么会发生这种情况,或者有更好的方法来处理这个问题?

回答

0

我重命名我的类,所以父类和子类不再有相同的名称,它似乎解决了这个问题。

0

的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.

不知道哪里来告诉你去处理这些信息,因为我还没有看到你的代码。但是,这可能是一个Android/Java错误,可能并不是你的错,或者你可能有一些递归的东西,你无法正确执行。