3

The following is my stacktrace. I looked through it but it just shows a bunch of views and frankly I'm not too sure what a stackoverflow error is exactly. I read on some of the other questions that some solved theirs through iterations (again, no idea what those are). For the basic layout of the app this is coming from when this crashes is:

TabView (5 tabs) > 5th tab > webview in that tab on button press. Now it does actually crash until i hit the back button to go back to the 5th tab and it doesn't do it every time.

Thanks for the help!

Edit: I stopped testing on the emulator and I have yet to see it crash on my phone. I will appreciate and look into any further help given but I think it was just an emulator issue.

04-20 01:52:26.510: ERROR/AndroidRuntime(23240): FATAL EXCEPTION: main
04-20 01:52:26.510: ERROR/AndroidRuntime(23240): java.lang.StackOverflowError
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewRoot.checkThread(ViewRoot.java:2801)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewRoot.requestChildFocus(ViewRoot.java:1567)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.requestChildFocus(ViewGroup.java:431)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.requestChildFocus(ViewGroup.java:431)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.requestChildFocus(ViewGroup.java:431)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.requestChildFocus(ViewGroup.java:431)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.requestChildFocus(ViewGroup.java:431)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.requestChildFocus(ViewGroup.java:431)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.handleFocusGainInternal(View.java:2486)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.requestFocus(View.java:3605)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.requestFocus(View.java:3556)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.requestFocus(View.java:3534)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.widget.TabWidget.onFocusChange(TabWidget.java:425)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.onFocusChanged(View.java:2666)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.handleFocusGainInternal(View.java:2489)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.handleFocusGainInternal(ViewGroup.java:405)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.requestFocus(View.java:3605)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.requestFocus(ViewGroup.java:1028)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.onRequestFocusInDescendants(ViewGroup.java:1073)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.requestFocus(ViewGroup.java:1029)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.requestFocus(View.java:3556)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.widget.TabHost$1.onKey(TabHost.java:121)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.dispatchKeyEvent(View.java:3735)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.widget.TabHost$1.onKey(TabHost.java:122)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.dispatchKeyEvent(View.java:3735)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.widget.TabHost$1.onKey(TabHost.java:122)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.dispatchKeyEvent(View.java:3735)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.widget.TabHost$1.onKey(TabHost.java:122)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.dispatchKeyEvent(View.java:3735)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.widget.TabHost$1.onKey(TabHost.java:122)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.dispatchKeyEvent(View.java:3735)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.widget.TabHost$1.onKey(TabHost.java:122)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.dispatchKeyEvent(View.java:3735)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.widget.TabHost$1.onKey(TabHost.java:122)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.dispatchKeyEvent(View.java:3735)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.widget.TabHost$1.onKey(TabHost.java:122)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.dispatchKeyEvent(View.java:3735)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.widget.TabHost$1.onKey(TabHost.java:122)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.dispatchKeyEvent(View.java:3735)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.widget.TabHost$1.onKey(TabHost.java:122)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.dispatchKeyEvent(View.java:3735)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.widget.TabHost$1.onKey(TabHost.java:122)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.dispatchKeyEvent(View.java:3735)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:788)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.widget.TabHost$1.onKey(TabHost.java:122)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.View.dispatchKeyEvent(View.java:3735)
04-20 01:52:26.510: ERROR/AndroidRuntime(23240):     at android.view.ViewGroup.d

Edit: Posting code on crash.

public class TwitterAuthUrl extends Activity {

    final static String TAG = "TwitterAuthUrl";
    WebView mWebView;

    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.twitterauthurl);
        Bundle extras = getIntent().getExtras();

        OAuthConsumer consumer = new DefaultOAuthConsumer("xxxxxxxxxxxxxxxxxxxxx",
        "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");

        OAuthProvider provider = new DefaultOAuthProvider(
        "http://twitter.com/oauth/request_token",
        "http://twitter.com/oauth/access_token",
        "http://twitter.com/oauth/authorize");


        String authUrl = null;
        try {
            authUrl = provider.retrieveRequestToken(consumer, OAuth.OUT_OF_BAND);
            Log.d(TAG, "Success authUrl " + authUrl);
        } catch (OAuthMessageSignerException e) {
            e.printStackTrace();
        } catch (OAuthNotAuthorizedException e) {
            e.printStackTrace();
        } catch (OAuthExpectationFailedException e) {
            e.printStackTrace();
        } catch (OAuthCommunicationException e) {
            e.printStackTrace();
        }

        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.loadUrl(authUrl);
        Log.d(TAG, "authUrl = " + authUrl);

    }
}

The XML:

<?xml version="1.0" encoding="utf-8"?>
    <WebView  xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/webview"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
    />
Taylor Kems
  • 337
  • 2
  • 4
  • 12

3 Answers3

7

You have too many nested viewgroups (see: java.lang.StackOverFlow error. Suspected too many views? for tips on how to reduce some of them)

Community
  • 1
  • 1
Gimbl
  • 1,500
  • 1
  • 13
  • 23
6

Usually this happens because in one of your methods, you keep calling yourself (we call it recursive call). Check your method to make sure you call super.whatever(), and not just whatever(). Also, it'd be great to post your code here so we can point to where exactly it happens.

Frank
  • 967
  • 1
  • 7
  • 12
  • That's not what happens in this case. If you look at the stack trace you can see that only Android classes are involved. – Elias Mårtenson Apr 20 '11 at 02:08
  • Helped me, thanks! When you start thinking about it, it's no good idea to call a method recursively even if the method must run again and again... :) – BurninLeo Jul 01 '12 at 22:15
1

Sometimes StackOverflowErrro can appear on only particular devices because they have different stack size you can read article about StackoverflowError.

Jacek Marchwicki
  • 1,565
  • 15
  • 17