title: Error java.lang.StackOverflowError: stack size 8MB
body: <p>I got an eror stack size. I hv no idea about this error. Because when I compile this project in another android studio. It works fine. But now in not working anymore and i got this error. This error will show when i choose an option in my radio group. I hv 2 radio group and edittext, when I choose the data from one of the radio group the other option in another radio group and edittext will be clear. But i got an error in the clear part in   setOnCheckedChangeListener function. Please help me. Thank you
  ChargeFragment.java</p>
  
  <pre><code>public class ChargeFragment extends Fragment {
  CustomerPreference customerPreference;
  DiscountPeferences discountPeferences;
  CartPreference cartPreference;
  SessionManagement sessionManagement;
  DatabaseHandler db;
  List&lt;CartModel&gt; cart;
  List&lt;Discount&gt; dp;
  
  Fragment fragment = null;
  
  Button Charge,Cancel;
  RadioButton rb1,rb2,rbEdc,rbOther,rbPay1,rbPay2,rbPay3;
  RadioGroup rg,rOther,rgPay;
  TextView tvTotal;
  EditText edCard,edCash;
  public ChargeFragment() {
      // Required empty public constructor
  }
  
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
                           Bundle savedInstanceState) {
      View rootview = inflater.inflate(R.layout.layout_charge, container, false);
  
      sessionManagement = new SessionManagement(getActivity());
      db = new DatabaseHandler(getActivity());
      cartPreference = new CartPreference();
      customerPreference = new CustomerPreference(getActivity());
      discountPeferences = new DiscountPeferences();
      cart = cartPreference.getFavorites(getActivity());
      dp = discountPeferences.getFavorites(getActivity());
  
      Bundle bun=this.getArguments();
      final int total=bun.getInt("total");
  
      tvTotal = (TextView) rootview.findViewById(R.id.tvTotal);
      rg = (RadioGroup) rootview.findViewById(R.id.radioChoose);
      rb1 = (RadioButton) rootview.findViewById(R.id.rd1);
      rb2 = (RadioButton) rootview.findViewById(R.id.rd2);
      rOther = (RadioGroup) rootview.findViewById(R.id.radioOther);
      rgPay = (RadioGroup) rootview.findViewById(R.id.rgPay);
      rbEdc = (RadioButton) rootview.findViewById(R.id.rdEdc);
      rbOther = (RadioButton) rootview.findViewById(R.id.rdOthr);
      rbPay1 = (RadioButton) rootview.findViewById(R.id.rdPay1);
      rbPay2 = (RadioButton) rootview.findViewById(R.id.rdPay2);
      rbPay3 = (RadioButton) rootview.findViewById(R.id.rdPay3);
      Charge = (Button) rootview.findViewById(R.id.buttonCharge);
      Cancel = (Button) rootview.findViewById(R.id.buttonCancel);
      edCard = (EditText) rootview.findViewById(R.id.edCard);
      edCash = (EditText) rootview.findViewById(R.id.edCash);
  
  
      int x = Math.round((total + 900)/1000 * 1000);
      int y = Math.round((total + 9000)/10000 * 10000);
      rbPay1.setText(""+total);
      rbPay2.setText(""+x);
      rbPay3.setText(""+y);
  
      final DecimalFormat kursIndonesia = (DecimalFormat) DecimalFormat.getCurrencyInstance();
      DecimalFormatSymbols formatRp = new DecimalFormatSymbols();
      formatRp.setCurrencySymbol("Rp. ");
      formatRp.setMonetaryDecimalSeparator(',');
      formatRp.setGroupingSeparator('.');
      kursIndonesia.setDecimalFormatSymbols(formatRp);
  
      tvTotal.setText(""+kursIndonesia.format(total));
  
      edCard.addTextChangedListener(new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
          }
  
          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
              rOther.clearCheck();
              rbEdc.setTextColor(Color.RED);
              rbOther.setTextColor(Color.RED);
          }
  
          @Override
          public void afterTextChanged(Editable editable) {
  
          }
      });
  
      edCash.addTextChangedListener(new TextWatcher() {
          @Override
          public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
  
          }
  
          @Override
          public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
              rg.clearCheck();
              rb1.setTextColor(Color.RED);
              rb2.setTextColor(Color.RED);
  
              rOther.clearCheck();
              rbEdc.setTextColor(Color.RED);
              rbOther.setTextColor(Color.RED);
  
          }
  
          @Override
          public void afterTextChanged(Editable editable) {
  
          }
      });
  
      rgPay.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(RadioGroup radioGroup, int i) {
              if(rbPay1.isChecked())
                  edCash.setText(rbPay1.getText().toString());
              if(rbPay2.isChecked())
                  edCash.setText(rbPay2.getText().toString());
              if(rbPay3.isChecked())
                  edCash.setText(rbPay3.getText().toString());
          }
      });
  
      rOther.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(RadioGroup radioGroup, int i) {
  
              rgPay.clearCheck();
              //edCash.setText("");
              if (rbEdc.isChecked()) {
                  rbEdc.setTextColor(Color.WHITE);
                  rbOther.setTextColor(Color.RED);
  
              }
              if (rbOther.isChecked()){
                  rbEdc.setTextColor(Color.RED);
                  rbOther.setTextColor(Color.WHITE);
  
              }
          }
      });
  
      rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(RadioGroup radioGroup, int i) {
  
             // rOther.clearCheck();
              rbEdc.setTextColor(Color.RED);
              rbOther.setTextColor(Color.RED);
              edCash.setText("");
              if (rb1.isChecked()) {
                  rb1.setTextColor(Color.WHITE);
                  rb2.setTextColor(Color.RED);
  
              }
              if (rb2.isChecked()){
                  rb1.setTextColor(Color.RED);
                  rb2.setTextColor(Color.WHITE);
  
              }
          }
      });
  
      Cancel.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              getActivity().onBackPressed();
          }
      });
      Charge.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
  
              int last=1;
  
              String method = "", pay = "";
              if (!edCash.getText().toString().equals("")) {
                  method = "Cash";
                  pay = edCash.getText().toString();
              } else if (!edCard.getText().toString().equals("")) {
                  method = "Debit/Credit";
                  pay = "" + total;
              } else if (edCard.getText().toString().equals("") &amp;&amp; edCash.getText().toString().equals("")) {
                  if (rbEdc.isChecked()) {
                      method = "EDC";
                  } else if (rbOther.isChecked()) {
                      method = "Other";
                  }
                  pay = "" + total;
              }
              String cardNo = "";
              if (edCard.getText().equals(""))
                  cardNo = "";
              else {
                  cardNo = edCard.getText().toString();
              }
  
              if(method.equals(""))
              {
                  Toast.makeText(getActivity(),"Choose Payment Method Please !",Toast.LENGTH_SHORT).show();
              }
              else {
  
                  String discID = "";
                  String discID2 = "";
                  int listDiscCount = db.getDiscCount();
                  if (dp != null) {
                      discID = db.getMaxIdListDiscount();
                      if (dp.size() &gt; 0) {
                          if (listDiscCount &gt; 0) {
                              discID2 = generateListDiscId(Integer.parseInt(discID.substring(discID.length() - 3)) + 1);
                          } else {
                              discID2 = generateListDiscId(1);
                          }
                          for (Discount d : dp) {
                              String pkDisc;
                              if (listDiscCount == 0)
                                  pkDisc = generateIdListDiscPk(1);
                              else {
                                  String lastPkDisc = db.getMaxPkIdListDiscount();
                                  pkDisc = generateIdListDiscPk(Integer.parseInt(lastPkDisc.substring(lastPkDisc.length() - 3)) + 1);
                              }
                              list_disc_nota ld = new list_disc_nota(pkDisc, discID2, d.getId());
                              db.addListDiscNota(ld);
                          }
                      }
                  }
  
                  insertItemNota();
  
  
                  int total1 = 0;
                  for (CartModel cm : cart) {
                      total1 = total1 + Integer.parseInt(cm.getHarga());
                  }
                  if (dp != null) {
                      if (dp.size() &gt; 0) {
                          InsertNota(method, discID2, cardNo, "" + total1, "" + total);
                      } else
                          InsertNota(method, "0", cardNo, "" + total1, "" + total);
                  } else {
                      InsertNota(method, "0", cardNo, "" + total1, "" + total);
                  }
  
  
                  int change = Integer.parseInt(pay) - total;
                  String nota = db.getLastNotaID();
                  if(method.equals("Debit/Credit"))
                  {
                      method="Card";
                  }
                  showPrint(nota, total, Integer.parseInt(pay), change,method);
              }
          }
      });
      return rootview;
  }
  </code></pre>
  
  <p>Error Stack</p>
  
  <pre><code>                  Process: com.project.pos.posandroid, PID: 2773
                    java.lang.StackOverflowError: stack size 8MB
                        at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5377)
                        at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
                        at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
                        at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
                        at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
                        at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
                        at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
                        at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
                        at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
                        at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
                        at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
                        at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
                        at android.view.View.getGlobalVisibleRect(View.java:12274)
                        at android.view.View.isVisibleToUser(View.java:6544)
                        at android.view.View.isVisibleToUser(View.java:6502)
                        at android.view.View.onInitializeAccessibilityNodeInfoInternal(View.java:6421)
                        at android.widget.TextView.onInitializeAccessibilityNodeInfoInternal(TextView.java:8978)
                        at android.view.View.onInitializeAccessibilityNodeInfo(View.java:6105)
                        at android.view.View.createAccessibilityNodeInfoInternal(View.java:6064)
                        at android.view.View.createAccessibilityNodeInfo(View.java:6049)
                        at android.view.accessibility.AccessibilityRecord.setSource(AccessibilityRecord.java:145)
                        at android.view.accessibility.AccessibilityRecord.setSource(AccessibilityRecord.java:119)
                        at android.view.View.onInitializeAccessibilityEventInternal(View.java:6001)
                        at android.widget.TextView.onInitializeAccessibilityEventInternal(TextView.java:8963)
                        at android.view.View.onInitializeAccessibilityEvent(View.java:5989)
                        at android.view.View.sendAccessibilityEventUncheckedInternal(View.java:5854)
                        at android.view.View.sendAccessibilityEventUnchecked(View.java:5839)
                        at android.view.View.sendAccessibilityEventInternal(View.java:5816)
                        at android.widget.TextView.sendAccessibilityEventInternal(TextView.java:9163)
                        at android.view.View.sendAccessibilityEvent(View.java:5783)
                        at android.widget.TextView.onSelectionChanged(TextView.java:7943)
                        at android.widget.TextView.spanChange(TextView.java:8160)
                        at android.widget.TextView$ChangeWatcher.onSpanAdded(TextView.java:10252)
                        at android.text.SpannableStringBuilder.sendSpanAdded(SpannableStringBuilder.java:1053)
                        at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:759)
                        at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:658)
                        at android.text.Selection.setSelection(Selection.java:78)
                        at android.text.Selection.setSelection(Selection.java:87)
                        at android.text.method.ArrowKeyMovementMethod.initialize(ArrowKeyMovementMethod.java:325)
                        at android.widget.TextView.setText(TextView.java:4354)
                        at android.widget.TextView.setText(TextView.java:4223)
                        at android.widget.EditText.setText(EditText.java:84)
                        at android.widget.TextView.setText(TextView.java:4198)
                        at com.project.pos.posandroid.Fragment.ChargeFragment$5.onCheckedChanged(ChargeFragment.java:209)
                        at android.widget.RadioGroup.setCheckedId(RadioGroup.java:173)
                        at android.widget.RadioGroup.check(RadioGroup.java:167)
                        at android.widget.RadioGroup.clearCheck(RadioGroup.java:209)
                        at com.project.pos.posandroid.Fragment.ChargeFragment$2.onTextChanged(ChargeFragment.java:155)
                        at android.widget.TextView.sendOnTextChanged(TextView.java:8048)
                        at android.widget.TextView.setText(TextView.java:4369)
                        at android.widget.TextView.setText(TextView.java:4223)
                        at android.widget.EditText.setText(EditText.java:84)
                        at android.widget.TextView.setText(TextView.java:4198)
                        at com.project.pos.posandroid.Fragment.ChargeFragment$5.onCheckedChanged(ChargeFragment.java:209)
                        at android.widget.RadioGroup.setCheckedId(RadioGroup.java:173)
                        at android.widget.RadioGroup.check(RadioGroup.java:167)
                      at android.widget.RadioGroup.clearChec
  I/art: Background partial concurrent mark sweep GC freed 5237(654KB) AllocSpace objects, 5(45MB) LOS objects, 22% free, 55MB/71MB, paused 689us total 130.901ms
  I/art: Background partial concurrent mark sweep GC freed 71632(8MB) AllocSpace objects, 4(27MB) LOS objects, 23% free, 52MB/68MB, paused 906us total 126.400ms
  D/Error: ERR: exClass=java.lang.StackOverflowError
  D/Error: ERR: exMsg=stack size 8MB
  D/Error: ERR: file=ViewGroup.java
  D/Error: ERR: class=android.view.ViewGroup
  D/Error: ERR: method=getChildVisibleRect line=5377
  I/art: Background sticky concurrent mark sweep GC freed 65308(8MB) AllocSpace objects, 0(0B) LOS objects, 0% free, 85MB/85MB, paused 8.070ms total 84.901ms
  D/Error: ERR: stack=java.lang.StackOverflowError: stack size 8MB
               at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5377)
               at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
               at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
               at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
               at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
               at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
               at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
               at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
               at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
               at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
               at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
               at android.view.ViewGroup.getChildVisibleRect(ViewGroup.java:5424)
               at android.view.View.getGlobalVisibleRect(View.java:12274)
               at android.view.View.isVisibleToUser(View.java:6544)
               at android.view.View.isVisibleToUser(View.java:6502)
               at android.view.View.onInitializeAccessibilityNodeInfoInternal(View.java:6421)
               at android.widget.TextView.onInitializeAccessibilityNodeInfoInternal(TextView.java:8978)
               at android.view.View.onInitializeAccessibilityNodeInfo(View.java:6105)
               at android.view.View.createAccessibilityNodeInfoInternal(View.java:6064)
               at android.view.View.createAccessibilityNodeInfo(View.java:6049)
               at android.view.accessibility.AccessibilityRecord.setSource(AccessibilityRecord.java:145)
               at android.view.accessibility.AccessibilityRecord.setSource(AccessibilityRecord.java:119)
               at android.view.View.onInitializeAccessibilityEventInternal(View.java:6001)
               at android.widget.TextView.onInitializeAccessibilityEventInternal(TextView.java:8963)
               at android.view.View.onInitializeAccessibilityEvent(View.java:5989)
               at android.view.View.sendAccessibilityEventUncheckedInternal(View.java:5854)
               at android.view.View.sendAccessibilityEventUnchecked(View.java:5839)
               at android.view.View.sendAccessibilityEventInternal(View.java:5816)
               at android.widget.TextView.sendAccessibilityEventInternal(TextView.java:9163)
               at android.view.View.sendAccessibilityEvent(View.java:5783)
               at android.widget.TextView.onSelectionChanged(TextView.java:7943)
               at android.widget.TextView.spanChange(TextView.java:8160)
               at android.widget.TextView$ChangeWatcher.onSpanAdded(TextView.java:10252)
               at android.text.SpannableStringBuilder.sendSpanAdded(SpannableStringBuilder.java:1053)
               at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:759)
               at android.text.SpannableStringBuilder.setSpan(SpannableStringBuilder.java:658)
               at android.text.Selection.setSelection(Selection.java:78)
               at android.text.Selection.setSelection(Selection.java:87)
               at android.text.method.ArrowKeyMovementMethod.initialize(ArrowKeyMovementMethod.java:325)
               at android.widget.TextView.setText(TextView.java:4354)
               at android.widget.TextView.setText(TextView.java:4223)
               at android.widget.EditText.setText(EditText.java:84)
               at android.widget.TextView.setText(TextView.java:4198)
               at com.project.pos.posandroid.Fragment.ChargeFragment$5.onCheckedChanged(ChargeFragment.java:209)
               at android.widget.RadioGroup.setCheckedId(RadioGroup.java:173)
               at android.widget.RadioGroup.check(RadioGroup.java:167)
               at android.widget.RadioGroup.clearCheck(RadioGroup.java:209)
               at com.project.pos.posandroid.Fragment.ChargeFragment$2.onTextChanged(ChargeFragment.java:155)
               at android.widget.TextView.sendOnTextChanged(TextView.java:8048)
               at android.widget.TextView.setText(TextView.java:4369)
               at android.widget.TextView.setText(TextView.java:4223)
               at android.widget.EditText.setText(EditText.java:84)
               at android.widget.TextView.setText(TextView.java:4198)
               at com.project.pos.posandroid.Fragment.ChargeFragment$5.onCheckedChanged(ChargeFragment.java:209)
               at android.widget.RadioGroup.setCheckedId(RadioGroup.java:173)
               at android.widget.RadioGroup.check(RadioGroup.java:167)
               at android.widget.RadioGroup.clearCheck(RadioGroup.java:209)
              at com.project.pos.posandroid.Fragment.Char
  D/Error: ERR: TOTAL BYTES WRITTEN: 10556588
  E/JavaBinder: !!! FAILED BINDER TRANSACTION !!!  (parcel size = 10556680)
  E/AndroidRuntime: Error reporting crash
                    android.os.TransactionTooLargeException: data parcel size 10556680 bytes
                        at android.os.BinderProxy.transactNative(Native Method)
                        at android.os.BinderProxy.transact(Binder.java:503)
                        at android.app.ActivityManagerProxy.handleApplicationCrash(ActivityManagerNative.java:4463)
                        at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:90)
                        at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
                        at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
  I/Process: Sending signal. PID: 2773 SIG: 9
  </code></pre>