title: android.view.InflateException: Binary XML file line #15: Error inflating class <unknown>
body: <p>I'm getting this error when I try to make an intent to a new <code>AppCompatActivity</code> but only in older Android APIs like 16, 22 or 23. In the new ones like API 26, it works correctly.</p>
  <p>This is the log:</p>
  <pre><code>android.view.InflateException: Binary XML file line #15: Binary XML file line #15: Error inflating class &lt;unknown&gt;
      at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
      at valientes.valientesappv2.Domain.Mensajes.MensajeriaAdapter.onCreateViewHolder(MensajeriaAdapter.java:37)
      at valientes.valientesappv2.Domain.Mensajes.MensajeriaAdapter.onCreateViewHolder(MensajeriaAdapter.java:25)
      at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6519)
      at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5706)
      at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5589)
      at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5585)
      at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2231)
      at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1558)
      at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1518)
      at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:585)
      at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3719)
      at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3436)
      at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3988)
      at android.view.View.layout(View.java:16630)
      at android.view.ViewGroup.layout(ViewGroup.java:5437)
      at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1079)
      at android.view.View.layout(View.java:16630)
      at android.view.ViewGroup.layout(ViewGroup.java:5437)
      at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
      at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
      at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
      at android.view.View.layout(View.java:16630)
      at android.view.ViewGroup.layout(ViewGroup.java:5437)
      at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
      at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
      at android.view.View.layout(View.java:16630)
      at android.view.ViewGroup.layout(ViewGroup.java:5437)
      at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1743)
      at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1586)
      at android.widget.LinearLayout.onLayout(LinearLayout.java:1495)
      at android.view.View.layout(View.java:16630)
      at android.view.ViewGroup.layout(ViewGroup.java:5437)
      at android.widget.FrameLayout.layoutChildren(FrameLayout.java:336)
      at android.widget.FrameLayout.onLayout(FrameLayout.java:273)
      at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2678)
      at android.view.View.layout(View.java:16630)
      at android.view.ViewGroup.layout(ViewGroup.java:5437)
      at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2171)
      at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1931)
      at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
      at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
      at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
      at android.view.Choreographer.doCallbacks(Choreographer.java:670)
      at android.view.Choreographer.doFrame(Choreographer.java:606)
      at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
      at android.os.Handler.handleCallback(Handler.java:739)
      at android.os.Handler.dispatchMessage(Handler.java:95)
      at android.os.Looper.loop(Looper.java:148)
      at android.app.ActivityThread.main(ActivityThread.java:5417)
      at java.lang.reflect.Method.invoke(Native Method)
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
   Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class &lt;u
  </code></pre>
  <p>The third line of this is where the exception's thrown:</p>
  <pre><code>@Override
  public MensajeriaAdapter.MensajesViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_view_mensajes,parent,false);
      return new MensajeriaAdapter.MensajesViewHolder(v);
  }
  </code></pre>
  <p>This is the layout:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:orientation=&quot;vertical&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;&gt;
      &lt;RelativeLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;match_parent&quot;&gt;
          &lt;EditText
              android:id=&quot;@+id/eTEsribirMensaje&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:hint=&quot;Escribe un mensaje...&quot;
              android:layout_alignParentBottom=&quot;true&quot;
              android:layout_alignParentLeft=&quot;true&quot;
              android:layout_alignParentStart=&quot;true&quot;
              android:layout_toLeftOf=&quot;@+id/bTenviarMensaje&quot;
              android:layout_toStartOf=&quot;@+id/bTenviarMensaje&quot; /&gt;
          &lt;Button
              android:id=&quot;@+id/bTenviarMensaje&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:hint=&quot;Enviar&quot;
              android:layout_alignParentBottom=&quot;true&quot;
              android:layout_alignParentRight=&quot;true&quot;
              android:layout_alignParentEnd=&quot;true&quot; /&gt;
          &lt;android.support.design.widget.AppBarLayout
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:id=&quot;@+id/appBarLayout&quot;
              android:theme=&quot;@style/AppTheme.AppBarOverlay&quot;&gt;
              &lt;android.support.v7.widget.Toolbar
                  android:id=&quot;@+id/toolbar&quot;
                  android:layout_width=&quot;match_parent&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  app:navigationIcon=&quot;?attr/homeAsUpIndicator&quot;
                  &gt;
                  &lt;RelativeLayout
                      android:layout_width=&quot;match_parent&quot;
                      android:layout_height=&quot;match_parent&quot;&gt;
                      &lt;ImageView
                          android:id=&quot;@+id/ivFoto&quot;
                          android:layout_width=&quot;45dp&quot;
                          android:layout_height=&quot;45dp&quot;
                          android:src=&quot;@mipmap/ic_launcher&quot; /&gt;
  
                      &lt;TextView
                          android:id=&quot;@+id/tvTitulo&quot;
                          android:layout_width=&quot;match_parent&quot;
                          android:layout_height=&quot;wrap_content&quot;
                          android:layout_centerVertical=&quot;true&quot;
                          android:gravity=&quot;center&quot;
                          android:text=&quot;Título&quot;
                          android:textSize=&quot;25dp&quot;
                          android:textColor=&quot;@color/colorWhite&quot;/&gt;
                  &lt;/RelativeLayout&gt;
              &lt;/android.support.v7.widget.Toolbar&gt;
          &lt;/android.support.design.widget.AppBarLayout&gt;
          &lt;android.support.v7.widget.RecyclerView
              android:id=&quot;@+id/rvMensajes&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              tools:listitem=&quot;@layout/card_view_mensajes&quot;
              android:layout_below=&quot;@+id/appBarLayout&quot;
              android:layout_alignParentLeft=&quot;true&quot;
              android:layout_alignParentStart=&quot;true&quot;
              android:layout_above=&quot;@+id/eTEsribirMensaje&quot;&gt;
          &lt;/android.support.v7.widget.RecyclerView&gt;
      &lt;/RelativeLayout&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  <p>And this is the cardViews I'm using in the <code>Recyclerview</code> of the layout:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:card_view=&quot;http://schemas.android.com/apk/res-auto&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:paddingLeft=&quot;5sp&quot;
      android:paddingRight=&quot;5sp&quot;&gt;
      &lt;android.support.v7.widget.CardView
          android:id=&quot;@+id/cvMensaje&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          card_view:cardBackgroundColor=&quot;@color/colorWhiteTransparent&quot;
          card_view:cardElevation=&quot;0dp&quot;&gt;
          &lt;LinearLayout
              android:id=&quot;@+id/mensajeBG&quot;
              android:layout_width=&quot;wrap_content&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:background=&quot;@drawable/out_message_bg&quot;
              android:orientation=&quot;vertical&quot;&gt;
              &lt;TextView
                  android:id=&quot;@+id/msTexto&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:maxWidth=&quot;240sp&quot;
                  android:text=&quot;hola, qué tal?&quot; /&gt;
              &lt;TextView
                  android:id=&quot;@+id/msHora&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:text=&quot;12:00 pm&quot;
                  android:textAppearance=&quot;?android:attr/textAppearanceSmall&quot;/&gt;
          &lt;/LinearLayout&gt;
      &lt;/android.support.v7.widget.CardView&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  <p>The Adapter class:</p>
  <pre><code> public class MensajeriaAdapter extends RecyclerView.Adapter&lt;MensajeriaAdapter.MensajesViewHolder&gt; {
  
      private List&lt;MensajeDeTexto&gt; mensajeDeTextos;
      private Context context;
  
      public MensajeriaAdapter(List&lt;MensajeDeTexto&gt; mensajeDeTextos, Context context) {
          this.mensajeDeTextos = mensajeDeTextos;
          this.context = context;
      }
  
      @Override
      public MensajeriaAdapter.MensajesViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.card_view_mensajes,parent,false);
          return new MensajeriaAdapter.MensajesViewHolder(v);
      }
  
      @Override
      public void onBindViewHolder(MensajeriaAdapter.MensajesViewHolder holder, int position) {
  
          RelativeLayout.LayoutParams rl = (RelativeLayout.LayoutParams) holder.cardView.getLayoutParams();
          FrameLayout.LayoutParams fl = (FrameLayout.LayoutParams) holder.mensajeBG.getLayoutParams();
  
          LinearLayout.LayoutParams llMensaje = (LinearLayout.LayoutParams) holder.TvMensaje.getLayoutParams();
          LinearLayout.LayoutParams llHora = (LinearLayout.LayoutParams) holder.TvHora.getLayoutParams();
  
          if(mensajeDeTextos.get(position).getTipoMensaje()==1){//EMISOR
              holder.mensajeBG.setBackgroundResource(R.drawable.in_message_bg);
              rl.addRule(RelativeLayout.ALIGN_PARENT_LEFT,0);
              rl.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
              llMensaje.gravity = Gravity.RIGHT;
              llHora.gravity = Gravity.RIGHT;
              fl.gravity = Gravity.RIGHT;
              holder.TvMensaje.setGravity(Gravity.RIGHT);
          }else if(mensajeDeTextos.get(position).getTipoMensaje()==2){//RECEPTOR
              holder.mensajeBG.setBackgroundResource(R.drawable.out_message_bg);
              rl.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,0);
              rl.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
              llMensaje.gravity = Gravity.LEFT;
              llHora.gravity = Gravity.LEFT;
              fl.gravity = Gravity.LEFT;
              holder.TvMensaje.setGravity(Gravity.LEFT);
          }
  
          holder.cardView.setLayoutParams(rl);
          holder.mensajeBG.setLayoutParams(fl);
          holder.TvMensaje.setLayoutParams(llMensaje);
          holder.TvHora.setLayoutParams(llHora);
  
          holder.TvMensaje.setText(mensajeDeTextos.get(position).getMensaje());
          holder.TvHora.setText(mensajeDeTextos.get(position).getHoraDelMensaje());
          if(android.os.Build.VERSION.SDK_INT &lt; Build.VERSION_CODES.LOLLIPOP) holder.cardView.getBackground().setAlpha(0);
          else holder.cardView.setBackgroundColor(ContextCompat.getColor(context,android.R.color.transparent));
      }
  
      @Override
      public int getItemCount() {
          return mensajeDeTextos.size();
      }
  
      static class MensajesViewHolder extends RecyclerView.ViewHolder{
  
          CardView cardView;
          LinearLayout mensajeBG;
          TextView TvMensaje;
          TextView TvHora;
  
          MensajesViewHolder(View itemView){
              super(itemView);
              cardView = (CardView) itemView.findViewById(R.id.cvMensaje);
              mensajeBG = (LinearLayout) itemView.findViewById(R.id.mensajeBG);
              TvMensaje = (TextView) itemView.findViewById(R.id.msTexto);
              TvHora = (TextView) itemView.findViewById(R.id.msHora);
          }
      }
  }
  </code></pre>
  <p>Anyone knows what could be the problem?</p>