java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

Stack Overflow | user1696992 | 1 month ago
tip
Do you find the tips below useful? Click on the to mark them and say thanks to rafael . Or join the community to write better ones.
  1. 0

    Rolling a dice based on number of sides

    Stack Overflow | 1 month ago | user1696992
    java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
  2. 0
    samebug tip
    This issue was solved in 2.2.6. If updating doesn't solve, try using notifyItemRangeChanged(1, mDatas.size()) instead of notifyItemRangeChanged(0, mDatas.size()).
  3. 0
    samebug tip
    If you're using notifyItemChanged(position) try changing it for notifyDataSetChanged().
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0
    samebug tip
    Also, you should dispatch events as soon as they happen, ReciclerView already bundles all updates.
  6. 0
    samebug tip
    When you use findViewById inside an activity it is going to look for a View inside your main_activity.xml. If it's not there, it throws this exception, try to use the right view to call findviewById.
Not finding the right solution?
Take a tour to get the most out of Samebug.

Tired of useless tips?

Automated exception search integrated into your IDE

Root Cause Analysis

  1. java.lang.IllegalStateException

    The specified child already has a parent. You must call removeView() on the child's parent first.

    at android.view.ViewGroup.addViewInner()
  2. Android Platform
    ViewGroup.addView
    1. android.view.ViewGroup.addViewInner(ViewGroup.java:4310)
    2. android.view.ViewGroup.addView(ViewGroup.java:4146)
    3. android.view.ViewGroup.addView(ViewGroup.java:4087)
    4. android.view.ViewGroup.addView(ViewGroup.java:4060)
    4 frames
  3. Android v7
    AppCompatActivity.setContentView
    1. android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:279)
    2. android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:145)
    2 frames
  4. com.example.thomb
    MainActivity$1.onClick
    1. com.example.thomb.tutorialspoint.MainActivity$1.onClick(MainActivity.java:25)
    1 frame
  5. Android Platform
    ActivityThread.main
    1. android.view.View.performClick(View.java:5280)
    2. android.view.View$PerformClick.run(View.java:21239)
    3. android.os.Handler.handleCallback(Handler.java:739)
    4. android.os.Handler.dispatchMessage(Handler.java:95)
    5. android.os.Looper.loop(Looper.java:234)
    6. android.app.ActivityThread.main(ActivityThread.java:5526)
    6 frames
  6. Java RT
    Method.invoke
    1. java.lang.reflect.Method.invoke(Native Method)
    1 frame
  7. Android
    ZygoteInit.main
    1. com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    2. com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    2 frames