Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error inflating class com.facebook.drawee.view.SimpleDraweeView

I'm trying to use the fresco library. I used it before too and it was working, but now, for some reason I get:

Unable to start activity ComponentInfo{com.example.home.template/com.example.home.template.MainActivity}: android.view.InflateException: Binary XML file line #26: Error inflating class com.facebook.drawee.view.SimpleDraweeView

My xml file:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              xmlns:fresco="http://schemas.android.com/apk/res-auto"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:orientation="vertical">


<com.facebook.drawee.view.SimpleDraweeView
        android:id="@+id/profileImage"
        fresco:actualImageScaleType="centerCrop"
        android:layout_width="200dp"
        android:layout_gravity="center_horizontal"
        android:layout_height="200dp" />
</LinearLayout>

MyApplication:

public class MyApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        FacebookSdk.sdkInitialize(this);
    }
}

I have it in my manifest: android:name=".MyApplication"

The only problem that I'm having is with the draweeview. I can do all of the other stuff such as logging in and taking information.

like image 781
Bogdan Daniel Avatar asked Apr 19 '16 16:04

Bogdan Daniel


People also ask

How do I load an image into a simpledraweeview?

The easiest way to load an image into a SimpleDraweeView is to call setImageURI: That’s it, you are now displaying images with Fresco! SimpleDraweeView, despite its name, supports a great deal of customization through XML attributes.

Can I use simpledraweeview in an XML layout?

These can be used in XML layouts. The simplest usage example of SimpleDraweeView is: NOTE: SimpleDraweeView does not support wrap_content for layout_width or layout_height attributes. More information can be found here.

Can I use wrap_content with simpledraweeview?

NOTE: SimpleDraweeView does not support wrap_content for layout_width or layout_height attributes. More information can be found here. The only exception to this is when you are setting an aspect ratio, like so:

How to display images with fresco in simpledraweeview?

The only exception to this is when you are setting an aspect ratio, like so: The easiest way to load an image into a SimpleDraweeView is to call setImageURI: That’s it, you are now displaying images with Fresco! SimpleDraweeView, despite its name, supports a great deal of customization through XML attributes.


3 Answers

In my case writing Fresco.initialize(this); before setContentView(R.layout.myxml); helped me.

Update:

you have FacebookSdk.sdkInitialize(this); instead of Fresco.initialize(this) in your myapplication

like image 176
Mounir Elfassi Avatar answered Oct 11 '22 00:10

Mounir Elfassi


I was getting this problem in API 19 devices just because I was using drawable vector as placeholder here

fresco:placeholderImage="@drawable/ic_phone"

After changing to PNG my problem was solved.

Dont forget to initialize it in your App as

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        Fresco.initialize(this)
    }
}

as well as this line in manifest's application

android:name=".App"
like image 26
Nux Avatar answered Oct 11 '22 00:10

Nux


Today I had the same problem. However, I forgot to add the property android:name=".MyApplication" in the AndroidManifest.xml.

like image 2
user3853134 Avatar answered Oct 11 '22 01:10

user3853134