Android - Exception Error inflating class com.facebook.drawee.view.SimpleDraweeView
<p>I published my app in the Play Store, in my tests there was no error, but the report I receive from Firebase, is presenting some problems in my adapter, tracking error and the code:</p>

<pre><code>Exception android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class com.facebook.drawee.view.SimpleDraweeView
android.view.LayoutInflater.inflate (LayoutInflater.java:539)
android.view.LayoutInflater.inflate (LayoutInflater.java:423)
br.com.topimagens.topimagens.adapters.ImageAdapter.onCreateViewHolder (ImageAdapter.java:85)
br.com.topimagens.topimagens.adapters.ImageAdapter.onCreateViewHolder (ImageAdapter.java:51)
android.support.v7.widget.RecyclerView$Adapter.createViewHolder (RecyclerView.java:5779)
android.support.v7.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:5003)
android.support.v7.widget.RecyclerView$Recycler.getViewForPosition (RecyclerView.java:4913)
android.support.v7.widget.LinearLayoutManager$LayoutState.next (LinearLayoutManager.java:2029)
android.support.v7.widget.LinearLayoutManager.layoutChunk (LinearLayoutManager.java:1414)
android.support.v7.widget.LinearLayoutManager.fill (LinearLayoutManager.java:1377)
android.support.v7.widget.LinearLayoutManager.onLayoutChildren (LinearLayoutManager.java:578)
android.support.v7.widget.RecyclerView.dispatchLayoutStep2 (RecyclerView.java:3260)
android.support.v7.widget.RecyclerView.dispatchLayout (RecyclerView.java:3069)
android.support.v7.widget.RecyclerView.onLayout (RecyclerView.java:3518)
android.view.View.layout (View.java:16646)
android.view.ViewGroup.layout (ViewGroup.java:5440)
android.support.design.widget.HeaderScrollingViewBehavior.layoutChild (HeaderScrollingViewBehavior.java:131)
android.support.design.widget.ViewOffsetBehavior.onLayoutChild (ViewOffsetBehavior.java:42)
android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onLayoutChild (AppBarLayout.java:1319)
android.support.design.widget.CoordinatorLayout.onLayout (CoordinatorLayout.java:817)
android.view.View.layout (View.java:16646)
android.view.ViewGroup.layout (ViewGroup.java:5440)
android.widget.RelativeLayout.onLayout (RelativeLayout.java:1079)
android.view.View.layout (View.java:16646)
android.view.ViewGroup.layout (ViewGroup.java:5440)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:336)
android.widget.FrameLayout.onLayout (FrameLayout.java:273)
android.view.View.layout (View.java:16646)
android.view.ViewGroup.layout (ViewGroup.java:5440)
android.widget.LinearLayout.setChildFrame (LinearLayout.java:1743)
android.widget.LinearLayout.layoutVertical (LinearLayout.java:1586)
android.widget.LinearLayout.onLayout (LinearLayout.java:1495)
android.view.View.layout (View.java:16646)
android.view.ViewGroup.layout (ViewGroup.java:5440)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:336)
android.widget.FrameLayout.onLayout (FrameLayout.java:273)
android.view.View.layout (View.java:16646)
android.view.ViewGroup.layout (ViewGroup.java:5440)
android.widget.LinearLayout.setChildFrame (LinearLayout.java:1743)
android.widget.LinearLayout.layoutVertical (LinearLayout.java:1586)
android.widget.LinearLayout.onLayout (LinearLayout.java:1495)
android.view.View.layout (View.java:16646)
android.view.ViewGroup.layout (ViewGroup.java:5440)
android.widget.FrameLayout.layoutChildren (FrameLayout.java:336)
android.widget.FrameLayout.onLayout (FrameLayout.java:273)
com.android.internal.policy.PhoneWindow$DecorView.onLayout (PhoneWindow.java:2678)
android.view.View.layout (View.java:16646)
android.view.ViewGroup.layout (ViewGroup.java:5440)
android.view.ViewRootImpl.performLayout (ViewRootImpl.java:2183)
android.view.ViewRootImpl.performTraversals (ViewRootImpl.java:1943)
android.view.ViewRootImpl.doTraversal (ViewRootImpl.java:1119)
android.view.ViewRootImpl$TraversalRunnable.run (ViewRootImpl.java:6060)
android.view.Choreographer$CallbackRecord.run (Choreographer.java:858)
android.view.Choreographer.doCallbacks (Choreographer.java:670)
android.view.Choreographer.doFrame (Choreographer.java:606)
android.view.Choreographer$FrameDisplayEventReceiver.run (Choreographer.java:844)
android.os.Handler.handleCallback (Handler.java:746)
android.os.Handler.dispatchMessage (Handler.java:95)
android.os.Looper.loop (Looper.java:148)
android.app.ActivityThread.main (ActivityThread.java:5443)
</code></pre>

<p>also part of those marking the same line:
<strong>Caused by android.view.InflateException: Binary XML file line #22: Error inflating class com.facebook.drawee.view.SimpleDraweeView
Caused by java.lang.reflect.InvocationTargetException:
Caused by java.lang.NullPointerException: SimpleDraweeView was not initialized!</strong></p>

<p>public class ImageAdapter extends RecyclerView.Adapter {
    private Context mContext;
    private List mList;
    public  SharedPreference sharedPreference ;
    private LayoutInflater mLayoutInflater;
    private float scale;
    private int width, height, roundPixels;
    protected static final String TAG = "LOG";
    private boolean withAnimation;
    private boolean withImagedLayout;</p>

<pre><code>public ImageAdapter(Context c, List&lt;Image&gt; l){
    this(c, l, true, true);
}
public ImageAdapter(Context c, List&lt;Image&gt; l, boolean wa, boolean wcl){
    mContext = c;
    mList = l;
    mLayoutInflater = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    sharedPreference = new SharedPreference();

    withAnimation = wa;
    withImagedLayout = wcl;

    scale = mContext.getResources().getDisplayMetrics().density;
    width = mContext.getResources().getDisplayMetrics().widthPixels - (int)(14 * scale + 0.5f);

    roundPixels = (int)(2 * scale + 0.5f);

}

@Override
public MyViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
    View v;
    MyViewHolder mvh;
        v = mLayoutInflater.inflate(R.layout.item_image_card, viewGroup, false);
        mvh = new MyViewHolder(v);
        v.setTag(viewGroup);


    return mvh;
}

@Override
public void onBindViewHolder(final MyViewHolder myViewHolder, int position) {

    myViewHolder.tvTitulo.setText(mList.get(position).getTitulo());

    Image image = getItem(position);
    myViewHolder.tvTitulo.setText(image.getTitulo());
    myViewHolder.tvTitulo.setText(image.getTitulo());

    if (checkFavoriteItem(image)) {
        myViewHolder.ivMenuFavorite.setImageResource(R.drawable.ico_heart_on);
        myViewHolder.ivMenuFavorite.setTag("red");
       // Log.e("Result: ", "red" );
    } else {
        myViewHolder.ivMenuFavorite.setImageResource(R.drawable.ico_heart_off);
        myViewHolder.ivMenuFavorite.setTag("grey");
        //Log.e("Result: ", "grey" );
    }

    ControllerListener listener = new BaseControllerListener(){
        @Override
        public void onFinalImageSet(String id, Object imageInfo, Animatable animatable) {
            super.onFinalImageSet(id, imageInfo, animatable);
            updateViewSize((ImageInfo) imageInfo);
        }

        @Override
        public void onFailure(String id, Throwable throwable) {
            super.onFailure(id, throwable);
        }

        @Override
        public void onIntermediateImageFailed(String id, Throwable throwable) {
            super.onIntermediateImageFailed(id, throwable);
        }

        @Override
        public void onIntermediateImageSet(String id, Object imageInfo) {
            super.onIntermediateImageSet(id, imageInfo);
            updateViewSize((ImageInfo) imageInfo);
        }

        @Override
        public void onRelease(String id) {
            super.onRelease(id);
        }

        @Override
        public void onSubmit(String id, Object callerContext) {
            super.onSubmit(id, callerContext);
        }

        void updateViewSize(@Nullable ImageInfo imageInfo) {
            if (imageInfo != null) {
                    //myViewHolder.ivImage.getLayoutParams().width = imageInfo.getWidth();
                    myViewHolder.ivImage.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT;
                    myViewHolder.ivImage.setAspectRatio((float) imageInfo.getWidth() / imageInfo.getHeight());
            }
        }

    };


    ImagePipeline imagePipeline = Fresco.getImagePipeline();

    ImageRequest imageRequest = ImageRequestBuilder
            .newBuilderWithSource(Uri.parse(mList.get(position).getPhoto()))
            .setRequestPriority(Priority.HIGH)
            .setLowestPermittedRequestLevel(ImageRequest.RequestLevel.FULL_FETCH)
            .build();

    DataSource&lt;CloseableReference&lt;CloseableImage&gt;&gt; dataSource =
            imagePipeline.fetchDecodedImage(imageRequest, mContext);

    try {
        dataSource.subscribe(new BaseBitmapDataSubscriber() {
            @Override
            public void onNewResultImpl(@Nullable Bitmap bitmap) {
                if (bitmap == null) {
                    Log.d(TAG, "Bitmap data source returned success, but bitmap null.");
                }

            }

            @Override
            public void onFailureImpl(DataSource dataSource) {
                // No cleanup required here
            }
        }, CallerThreadExecutor.getInstance());
    } finally {
        if (dataSource != null) {
            dataSource.close();
        }
    }

    Uri uri = Uri.parse( mList.get(position).getPhoto() );
    DraweeController dc = Fresco.newDraweeControllerBuilder()
            .setUri( uri )
            .setTapToRetryEnabled(true)
            .setControllerListener( listener )
            .setOldController( myViewHolder.ivImage.getController() )
            .build();

    RoundingParams rp = RoundingParams.fromCornersRadii(roundPixels, roundPixels, 0, 0);
    myViewHolder.ivImage.setController(dc);
    myViewHolder.ivImage.getHierarchy().setRoundingParams( rp );

    if(withAnimation){
        try{
            YoYo.with(Techniques.ZoomIn)
                    .duration(700)
                    .playOn(myViewHolder.itemView);
        }
        catch(Exception e){}
    }

}

public Image getItem(int position) {
    return mList.get(position);
}

public int getItemCount() {
    return null!=mList?mList.size():0;
}

public void addListItem(Image c, int position){
    mList.add(position, c);
    notifyItemInserted(position);
}


public void removeListItem(int position){
    mList.remove(position);
    notifyItemRemoved(position);
}

public class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
    public SimpleDraweeView ivImage;
    public TextView tvTitulo;
    public TextView ivContextMenuWhats;
    public TextView ivContextMenuFace;
    public TextView ivContextMenuShare;
    public ImageView ivMenuFavorite;


    public MyViewHolder(View itemView) {
        super(itemView);
        //int position =  (int) itemView.getTag();
        ivImage = (SimpleDraweeView) itemView.findViewById(R.id.iv_image);
        tvTitulo = (TextView) itemView.findViewById(R.id.tv_titulo);
        ivContextMenuWhats = (TextView) itemView.findViewById(R.id.iv_buttom_whats);
        ivContextMenuFace = (TextView) itemView.findViewById(R.id.iv_buttom_face);
        ivContextMenuShare = (TextView) itemView.findViewById(R.id.iv_buttom_share);
        ivMenuFavorite = (ImageView) itemView.findViewById(R.id.iv_buttom_favorite);


        if( ivContextMenuWhats != null ){
            ivContextMenuWhats.setOnClickListener(this);
        }
        if( ivContextMenuFace != null ){
            ivContextMenuFace.setOnClickListener(this);
        }
        if( ivContextMenuShare != null ){
            ivContextMenuShare.setOnClickListener(this);
        }
        if( ivMenuFavorite != null ){
            ivMenuFavorite.setOnClickListener(this);
        }

    }


    public void onClick(View v) {

        Image image = mList.get(getAdapterPosition());
        String tag = ivMenuFavorite.getTag().toString();

        switch (v.getId()) {
            case R.id.iv_buttom_whats: {
                FirebaseCrash.log("ImageAdapter:onClick:iv_buttom_whats");
                if (isPackageInstalled("com.whatsapp")) {
                    new MyAsyncTask(mContext, mList.get(getAdapterPosition()).getFoto(), mList.get(getAdapterPosition()).getPhoto(), "com.whatsapp").execute();
                } else {
                    Toast.makeText(mContext, mContext.getString(R.string.txt_whatsapp_not_faund), Toast.LENGTH_SHORT).show();
                }
                break;
            }

            case R.id.iv_buttom_face: {
                FirebaseCrash.log("ImageAdapter:onClick:iv_buttom_face");
                if (isPackageInstalled("com.facebook.katana")) {
                    new MyAsyncTask(mContext, mList.get(getAdapterPosition()).getFoto(), mList.get(getAdapterPosition()).getPhoto(), "com.facebook.katana").execute();
                } else {
                    Toast.makeText(mContext, mContext.getString(R.string.txt_facebook_not_faund), Toast.LENGTH_SHORT).show();
                }
                break;
            }

            case R.id.iv_buttom_share: {
                FirebaseCrash.log("ImageAdapter:onClick:iv_buttom_share");
                new MyAsyncTask(mContext, mList.get(getAdapterPosition()).getFoto(), mList.get(getAdapterPosition()).getPhoto(), "share").execute();
                break;
            }
            case R.id.iv_buttom_favorite: {
                FirebaseCrash.log("ImageAdapter:onClick:iv_buttom_favorite");
            if (tag.equalsIgnoreCase("grey")) {
                sharedPreference.addFavorite(mContext, image);
                Toast.makeText(mContext,
                mContext.getResources().getString(R.string.txt_favorite_add),
                Toast.LENGTH_SHORT).show();
                //Toast.makeText(mContext, image.toString(), Toast.LENGTH_LONG).show();
                //Log.e("Cor red", tag);
                ivMenuFavorite.setTag("red");
                ivMenuFavorite.setImageResource(R.drawable.ico_heart_on);
            } else {
                sharedPreference.removeFavorite(mContext, image);
                ivMenuFavorite.setTag("grey");
                ivMenuFavorite.setImageResource(R.drawable.ico_heart_off);
                // Toast.makeText(mContext, "remove" + qid ,Toast.LENGTH_SHORT).show();
                Toast.makeText(mContext,
                mContext.getResources().getString(R.string.txt_remove_favorite),
                Toast.LENGTH_SHORT).show();
                //Log.e("Cor grey", tag);
            }

                break;
            }
        }
    }


    public boolean isPackageInstalled(String packagename) {
        PackageManager pm = mContext.getPackageManager();
        try {
            pm.getPackageInfo(packagename, PackageManager.GET_ACTIVITIES);
            return true;
        } catch (PackageManager.NameNotFoundException e) {
            return false;
        }
    }
}

public boolean checkFavoriteItem(Image checkImage) {
    boolean check = false;
    List&lt;Image&gt; myList = sharedPreference.getFavorites(mContext);
    if (myList != null) {
        for (Image image : myList) {
            if (image.equals(checkImage)) {
                check = true;

                break;
            }
        }            
    }
    return check;
}
</code></pre>

<p>}</p>

<p>Code xml:
</p>

<pre><code>&lt;RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#f8f8f8"&gt;

    &lt;com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/iv_image"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_alignParentTop="true"
        fresco:actualImageScaleType="center"
        fresco:failureImage="@drawable/error_img"
        fresco:placeholderImage="@drawable/loading_img"
        fresco:retryImage="@drawable/retry_img" /&gt;

    &lt;TextView
        android:id="@+id/tv_titulo"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#f8f8f8"
        android:layout_below="@+id/iv_image"
        android:padding="8dp"
        android:textColor="@color/colorPrimarytext"
        android:textSize="14sp" /&gt;

    &lt;TextView
        android:textSize="12sp"
        android:textStyle="bold"
        android:textColor="#fff"
        android:ellipsize="marquee"
        android:gravity="top|bottom|center_vertical|fill_vertical|center|fill"
        android:id="@+id/iv_buttom_whats"
        android:background="@drawable/border_corner"
        android:paddingBottom="8dp"
        android:padding="8dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/compartilhar_no_whatsapp"
        android:singleLine="true"
        android:drawableLeft="@drawable/ic_whatsapp_white"
        android:drawablePadding="8dp"
        android:marqueeRepeatLimit="marquee_forever"
        android:layout_below="@+id/tv_titulo"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp" /&gt;

    &lt;TextView
        android:textSize="12sp"
        android:textStyle="bold"
        android:textColor="#fff"
        android:ellipsize="marquee"
        android:gravity="top|bottom|center_vertical|fill_vertical|center|fill"
        android:id="@+id/iv_buttom_face"
        android:background="@drawable/border_corner_face"
        android:padding="8dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:drawableLeft="@drawable/ic_facebook_white"
        android:drawablePadding="8dp"
        android:marqueeRepeatLimit="marquee_forever"
        android:layout_below="@+id/tv_titulo"
        android:layout_toRightOf="@+id/iv_buttom_whats"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp" /&gt;

    &lt;TextView
        android:textSize="12sp"
        android:textStyle="bold"
        android:textColor="#fff"
        android:ellipsize="marquee"
        android:gravity="top|bottom|center_vertical|fill_vertical|center|fill"
        android:id="@+id/iv_buttom_share"
        android:background="@drawable/border_corner_share"
        android:padding="8dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:drawableLeft="@drawable/ic_share_white"
        android:drawablePadding="8dp"
        android:marqueeRepeatLimit="marquee_forever"
        android:layout_below="@+id/tv_titulo"
        android:layout_toRightOf="@+id/iv_buttom_face"
        android:layout_toEndOf="@+id/iv_buttom_face"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp" /&gt;

    &lt;ImageView
        android:textSize="12sp"
        android:textStyle="bold"
        android:textColor="#fff"
        android:ellipsize="marquee"
        android:gravity="top|bottom|center_vertical|fill_vertical|center|fill"
        android:id="@+id/iv_buttom_favorite"
        android:padding="8dp"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:background="@null"
        android:drawablePadding="8dp"
        android:marqueeRepeatLimit="marquee_forever"
        android:layout_below="@+id/tv_titulo"
        android:layout_toRightOf="@+id/iv_buttom_share"
        android:layout_toEndOf="@+id/iv_buttom_share"
        android:layout_marginLeft="8dp"
        android:layout_marginStart="8dp"
        android:contentDescription="@string/favorites"
        android:clickable="true" /&gt;

    &lt;Space
        android:layout_width="match_parent"
        android:layout_height="2dp"
        android:layout_below="@+id/iv_buttom_whats"
        android:layout_centerHorizontal="true" /&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p></p>

<p>I thank anyone who can help me</p>