'int android.view.View.getVisibility()' on a null object reference
<p>I am using recyclerview and suddenly getting a weird error. I have tried everything that i could. Even placed Breakpoint. but it does not reach anywhere. There is data in the arraylist. I have tried all the solution that is available on StackOverFlow. It still does not work and also the solution available are for ListView. I am using recycerview so I am unable to get the solution. There is no null value.
 My recycler adapter is as below:</p>

<pre><code>private class RecyclerAdapter extends RecyclerView.Adapter&lt;RecyclerViewHolders&gt; {

    private Context context;
    private ArrayList&lt;Integer&gt; arrayTarget = new ArrayList&lt;&gt;();
    private ArrayList&lt;Integer&gt; arrayAchievements = new ArrayList&lt;&gt;();
    private ArrayList&lt;String&gt; arrayAssociateName = new ArrayList&lt;&gt;();
    private ArrayList&lt;String&gt; arrayUserType = new ArrayList&lt;&gt;();
    private ArrayList&lt;Integer&gt; arrayAchievedGrp = new ArrayList&lt;&gt;();


    public RecyclerAdapter(Context c, ArrayList&lt;Integer&gt; arrayTarget,
                           ArrayList&lt;String&gt; arrayAssociateName, ArrayList&lt;Integer&gt; arrayAchievements,
                           ArrayList&lt;String&gt; arrayUserType, ArrayList&lt;Integer&gt; arrayAchievedGrp) {
        this.context = c;
        this.arrayTarget = arrayTarget;
        this.arrayAchievements = arrayAchievements;
        this.arrayAssociateName = arrayAssociateName;
        this.arrayUserType = arrayUserType;
        this.arrayAchievedGrp = arrayAchievedGrp;

    }


    @Override
    public RecyclerViewHolders onCreateViewHolder(ViewGroup parent, int viewType) {
        View layout = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.row_associates_list, parent, false);

        return new RecyclerViewHolders(layout);
    }

    //this will attach the row at different positions
    @Override
    public void onBindViewHolder(RecyclerViewHolders mHolder, final int pos) {

        mHolder.tv_AssociateName.setText(arrayAssociateName.get(pos).toUpperCase());
        mHolder.tv_target.setText(String.valueOf(arrayTarget.get(pos)));
        mHolder.tv_achievements.setText(String.valueOf(arrayAchievements.get(pos)));
        mHolder.tv_AssociateType.setText(" ( " + arrayUserType.get(pos) + " )");
        mHolder.tv_achievedSraGrp.setText(String.valueOf(arrayAchievedGrp.get(pos)));
        try {
            percentage = (arrayAchievements.get(pos) * 100) / arrayTarget.get(pos);
            if (percentage &gt; 100) {
                percentage = 100;
            }
        } catch (Exception e) {
            e.printStackTrace();
            percentage = 0;
        }

        arrayPercentage.add(percentage);
        mHolder.tv_percentage.setText(String.valueOf(percentage) + "%");

    }

    @Override
    public int getItemCount() {
        return arrayAssociateName.size();
    }
}

public class RecyclerViewHolders extends RecyclerView.ViewHolder implements View.OnClickListener {

    TextView tv_AssociateName, tv_target, tv_achievements, tv_percentage, tv_AssociateType, tv_achievedSraGrp;
    ImageButton ib_alertButton;
    LinearLayout LL_achievedGrp;

    public RecyclerViewHolders(View itemView) {
        super(itemView);
        itemView.setOnClickListener(this);
        tv_AssociateName = (TextView) itemView.findViewById(R.id.tv_AssociateName);
        tv_target = (TextView) itemView.findViewById(R.id.tv_target);
        tv_achievements = (TextView) itemView.findViewById(R.id.tv_achievements);
        tv_percentage = (TextView) itemView.findViewById(R.id.tv_percentage);
        tv_AssociateType = (TextView) itemView.findViewById(R.id.tv_AssociateType);
        tv_achievedSraGrp = (TextView) itemView.findViewById(R.id.tv_achievedSraGrp);
        LL_achievedGrp = (LinearLayout) itemView.findViewById(R.id.LL_achievedGrp);

        ib_alertButton = (ImageButton) itemView.findViewById(R.id.ib_alertButton);
        ib_alertButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Toast.makeText(getApplicationContext(), "Coming Soon..", Toast.LENGTH_LONG).show();
            }
        });

        if (mainUserType.equalsIgnoreCase("ASE")) {
            LL_achievedGrp.setVisibility(View.VISIBLE);
        } else {
            LL_achievedGrp.setVisibility(View.GONE);
        }
    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent(getApplicationContext(), AssociatesDashboard.class);
        intent.putExtra("empCode", arrayAssociateEmpCd.get(getLayoutPosition()));    //to open dashboard for this user
        intent.putExtra("strActivityName", ActivityConstant.ASSOCIATE_LIST);
        intent.putExtra("userType", callingUser);

    }
}
</code></pre>

<p>The constructor is called. But then getting the error without any location. LogCat as below:</p>

<pre><code>FATAL EXCEPTION: main
                                                                           Process: com.mapmymarketing.salesscope, PID: 24220
                                                                           java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.View.getVisibility()' on a null object reference
                                                                               at android.widget.LinearLayout.forceUniformHeight(LinearLayout.java:1380)
                                                                               at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1368)
                                                                               at android.widget.TableRow.onMeasure(TableRow.java:114)
                                                                               at android.view.View.measure(View.java:17547)
                                                                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
                                                                               at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
                                                                               at android.widget.TableLayout.measureChildBeforeLayout(TableLayout.java:464)
                                                                               at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
                                                                               at android.widget.TableLayout.measureVertical(TableLayout.java:476)
                                                                               at android.widget.TableLayout.onMeasure(TableLayout.java:439)
                                                                               at android.view.View.measure(View.java:17547)
                                                                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
                                                                               at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
                                                                               at android.support.v7.widget.CardView.onMeasure(CardView.java:211)
                                                                               at android.view.View.measure(View.java:17547)
                                                                               at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:727)
                                                                               at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:463)
                                                                               at android.view.View.measure(View.java:17547)
                                                                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
                                                                               at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:706)
                                                                               at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:90)
                                                                               at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1364)
                                                                               at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:771)
                                                                               at android.view.View.measure(View.java:17547)
                                                                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
                                                                               at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
                                                                               at android.view.View.measure(View.java:17547)
                                                                               at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1085)
                                                                               at android.view.View.measure(View.java:17547)
                                                                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
                                                                               at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
                                                                               at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:135)
                                                                               at android.view.View.measure(View.java:17547)
                                                                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
                                                                               at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
                                                                               at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
                                                                               at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
                                                                               at android.view.View.measure(View.java:17547)
                                                                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
                                                                               at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
                                                                               at android.view.View.measure(View.java:17547)
                                                                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
                                                                               at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1436)
                                                                               at android.widget.LinearLayout.measureVertical(LinearLayout.java:722)
                                                                               at android.widget.LinearLayout.onMeasure(LinearLayout.java:613)
                                                                               at android.view.View.measure(View.java:17547)
                                                                               at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5535)
                                                                               at android.widget.FrameLayout.onMeasure(FrameLayout.java:436)
                                                                               at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2615)
                                                                               at android.view.View.measure(View.java:17547)
                                                                               at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2015)
                                                                               at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1173)
                                                                               at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1379)
                                                                               at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1061)
                                                                               at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5885)
                                                                               at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
                                                                            at android.vi
</code></pre>

<p>This is the XML of recycler adapter row:</p>

<pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/ll_card"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:background="@color/white"
android:orientation="vertical"&gt;

&lt;android.support.v7.widget.CardView
    android:id="@+id/CardView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:paddingBottom="20dp"
    android:paddingTop="20dp"
    app:cardElevation="4dp"&gt;

    &lt;LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"
        android:orientation="vertical"&gt;

        &lt;LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:layout_marginStart="5dp"
            android:layout_marginTop="5dp"
            android:orientation="horizontal"&gt;

            &lt;TextView
                android:id="@+id/tv_AssociateName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:padding="5dp"
                android:text="Swaroop Pandey"
                android:textColor="@color/black"
                android:textSize="15sp"
                android:textStyle="bold" /&gt;

            &lt;TextView
                android:id="@+id/tv_AssociateType"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginStart="10dp"
                android:text="SO"
                android:textColor="@color/PrimaryDark2"
                android:textSize="15sp"
                android:textStyle="bold" /&gt;

            &lt;TextView
                android:id="@+id/tv_percentage"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginRight="10dp"
                android:gravity="end"
                android:text="50 %"
                android:textColor="@color/pink"
                android:textSize="20sp"
                android:textStyle="bold" /&gt;
        &lt;/LinearLayout&gt;

        &lt;LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:layout_marginStart="10dp"
            android:layout_marginTop="5dp"
            android:orientation="horizontal"&gt;


            &lt;TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:text="Target - "
                android:textColor="@color/black"
                android:textSize="15sp" /&gt;

            &lt;TextView
                android:id="@+id/tv_target"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="5dp"
                android:layout_marginLeft="10dp"
                android:layout_marginStart="10dp"
                android:text="10000"
                android:textColor="@color/PrimaryDark2"
                android:textSize="15sp" /&gt;
        &lt;/LinearLayout&gt;

        &lt;LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="10dp"
            android:layout_marginStart="10dp"
            android:orientation="horizontal"&gt;

            &lt;TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Achievements - "
                android:textColor="@color/black"
                android:textSize="15sp" /&gt;

            &lt;TextView
                android:id="@+id/tv_achievements"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="10dp"
                android:layout_marginStart="10dp"
                android:text="5000"
                android:textColor="@color/PrimaryDark2"
                android:textSize="15sp" /&gt;
        &lt;/LinearLayout&gt;

        &lt;RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="10dp"
            android:layout_marginStart="10dp"&gt;

            &lt;LinearLayout
                android:id="@+id/LL_achievedGrp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:orientation="horizontal"&gt;

                &lt;TextView
                    android:id="@+id/tv_text"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="5dp"
                    android:text="Achieved SRA Group - "
                    android:textColor="@color/black"
                    android:textSize="15sp" /&gt;

                &lt;TextView
                    android:id="@+id/tv_achievedSraGrp"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="3"
                    android:textColor="@color/PrimaryDark2"
                    android:textSize="15sp" /&gt;
            &lt;/LinearLayout&gt;

            &lt;ImageButton
                android:id="@+id/ib_alertButton"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_marginEnd="10dp"
                android:layout_marginRight="10dp"
                android:background="@drawable/alert" /&gt;
        &lt;/RelativeLayout&gt;
    &lt;/LinearLayout&gt;
&lt;/android.support.v7.widget.CardView&gt;
</code></pre>

<p></p>

<p>This is the Layout (main layout) which contains TableRow layout</p>

<pre><code>&lt;RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"&gt;

    &lt;android.support.v7.widget.CardView
        android:id="@+id/cardView2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:elevation="5dp"
        app:cardBackgroundColor="@color/background"&gt;

        &lt;TableLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="10dp"&gt;

            &lt;TableRow
                android:layout_width="match_parent"
                android:layout_height="match_parent"&gt;

                &lt;ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_column="1"
                    android:layout_marginEnd="10dp"
                    android:layout_marginRight="10dp"
                    android:src="@drawable/blue_ring" /&gt;

                &lt;TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_column="2"
                    android:layout_weight="3.5"
                    android:text="Total Associates"
                    android:textColor="@color/white"
                    android:textSize="15sp" /&gt;

                &lt;TextView
                    android:id="@+id/tv_totalTarget"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_column="3"
                    android:layout_weight="1"
                    android:gravity="end|center"
                    android:text="3000"
                    android:textColor="@color/white"
                    android:textSize="15sp" /&gt;

                &lt;TextView
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_column="4"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:layout_weight="1"
                    android:gravity="end|center"
                    android:text="100%"
                    android:textColor="#8b8ce6"
                    android:textSize="15sp" /&gt;
            &lt;/TableRow&gt;

            &lt;View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginBottom="5dp"
                android:layout_marginTop="10dp"
                android:background="#30ffffff" /&gt;

            &lt;TableRow
                android:layout_width="match_parent"
                android:layout_height="wrap_content"&gt;

                &lt;ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_column="1"
                    android:layout_marginEnd="10dp"
                    android:layout_marginRight="10dp"
                    android:src="@drawable/green_ring" /&gt;

                &lt;TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_column="2"
                    android:layout_weight="3.5"
                    android:text="Associate achieved upto 5 group"
                    android:textColor="@color/white"
                    android:textSize="15sp" /&gt;

                &lt;TextView
                    android:id="@+id/tv_totalAchievements"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_column="3"
                    android:layout_weight="1"
                    android:gravity="end|center"
                    android:text="1500"
                    android:textColor="@color/Primary"
                    android:textSize="15sp" /&gt;

                &lt;TextView
                    android:id="@+id/tv_achievementsPercentage"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_column="4"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:layout_weight="1"
                    android:gravity="end|center"
                    android:text="50%"
                    android:textColor="#51e4ca"
                    android:textSize="15sp" /&gt;
            &lt;/TableRow&gt;

            &lt;View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginBottom="5dp"
                android:layout_marginTop="10dp"
                android:background="#30ffffff" /&gt;

            &lt;TableRow
                android:layout_width="match_parent"
                android:layout_height="wrap_content"&gt;

                &lt;ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_column="1"
                    android:layout_marginEnd="10dp"
                    android:layout_marginRight="10dp"
                    android:src="@drawable/orange_ring" /&gt;

                &lt;TextView
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_column="2"
                    android:layout_weight="3.5"
                    android:text="Associates achieved less than 5 group"
                    android:textColor="@color/white"
                    android:textSize="15sp" /&gt;

                &lt;TextView
                    android:id="@+id/tv_totalGap"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_column="3"
                    android:layout_weight="1"
                    android:gravity="end|center"
                    android:text="1500"
                    android:textColor="@color/Primary"
                    android:textSize="15sp" /&gt;

                &lt;TextView
                    android:id="@+id/tv_gapPercentage"
                    android:layout_width="0dp"
                    android:layout_height="match_parent"
                    android:layout_column="4"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:layout_weight="1"
                    android:gravity="end|center"
                    android:text="50%"
                    android:textColor="#ed9178"
                    android:textSize="15sp" /&gt;
            &lt;/TableRow&gt;
        &lt;/TableLayout&gt;
    &lt;/android.support.v7.widget.CardView&gt;

    &lt;android.support.v7.widget.RecyclerView
        android:id="@+id/AssociateList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/cardView2"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="10dp" /&gt;

    &lt;TextView
        android:id="@+id/no_data_available"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/cardView2"
        android:layout_gravity="center"
        android:gravity="center"
        android:padding="10dp"
        android:text="No Data Available"
        android:textColor="@color/white"
        android:visibility="gone" /&gt;
&lt;/RelativeLayout&gt;
</code></pre>