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

Created on 2 Apr 2015  ·  29Comments  ·  Source: facebook/fresco

Hi.
I've tried to inflate this guy on adapter, but don't work!
I'm using the last version.

<com.facebook.drawee.view.SimpleDraweeView
  android:id="@+id/camera_image"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  app:placeholderImage="@mipmap/ic_launcher"/>

android.view.InflateException: Binary XML file line #7: Error inflating class com.facebook.drawee.view.SimpleDraweeView...

Most helpful comment

    <com.facebook.drawee.view.SimpleDraweeView
            android:layout_gravity="center"
            android:layout_height="100dp"
            android:layout_width="100dp"
            android:background="@color/white"
            android:id="@+id/cover"/>
android.view.InflateException: Binary XML file line #13: Error inflating class com.facebook.drawee.view.SimpleDraweeView
            at android.view.LayoutInflater.createView(LayoutInflater.java:620)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)

I hava the same trouble~

Solve Method

You should only call Fresco.initialize once. Your Application class would be a good place. Doing it in each Activity is wrong.

add :Fresco.initialize(this); to your Application class.

All 29 comments

Is there anything else in the error message? That should probably be fb:placeholderImage= instead of app:placeholderImage=

@IanChilds, This hasn't relation with the problem. If I remove this line, the problem still happens.

    <com.facebook.drawee.view.SimpleDraweeView
            android:layout_gravity="center"
            android:layout_height="100dp"
            android:layout_width="100dp"
            android:background="@color/white"
            android:id="@+id/cover"/>
android.view.InflateException: Binary XML file line #13: Error inflating class com.facebook.drawee.view.SimpleDraweeView
            at android.view.LayoutInflater.createView(LayoutInflater.java:620)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:397)

I hava the same trouble~

Solve Method

You should only call Fresco.initialize once. Your Application class would be a good place. Doing it in each Activity is wrong.

add :Fresco.initialize(this); to your Application class.

@ppamorim I have solve this problem.
add :Fresco.initialize(this); to your Application.

Thanks for your response andforce

it's right

This is so tricky. The error message seems totally irrelevant with the solution.

I have placed the Fresco.initialize(this); in my application, but still error is there...

@Override
protected void onCreate(Bundle savedInstanceState)
{

    super.onCreate(savedInstanceState);
    Fresco.initialize(this);
    setContentView(R.layout.activity_main);



    Uri uri = Uri.parse("https://raw.githubusercontent.com/facebook/fresco/gh-pages/static/fresco-logo.png");
    SimpleDraweeView draweeView = (SimpleDraweeView) findViewById(R.id.my_image_view);
    draweeView.setImageURI(uri);
}

Above is the code... Please Please Please Help me Friends...

In case you want to implement using a fragment as would be? I have the same problem as everyone else. Best Regards!

Is this the same stack trace as issue #395?

you guys sure you registered the application in the manifest? its a small step,but your context wont be valid when you try to init Fresco without
android:name="your application name"

I have the same problem too~how can i solve it?

ok,I solved it.
just put

Fresco.initialize(this);

above

setContentView(R.layout.activity_main);

and ,it works now.

thanks it worked

@ManMegh @vivian8725118 You should only call Fresco.initialize once. Your Application class would be a good place. Doing it in each Activity is wrong.

Thanks bro worked perfectly though not using fresco am using picasso.
Regards

On Fri, Oct 9, 2015 at 7:32 AM, andforce [email protected] wrote:

@ManMegh https://github.com/ManMegh @vivian8725118
https://github.com/vivian8725118 You should only call Fresco.initialize
once. Your Application class would be a good place. Doing it in each
Activity is wrong.


Reply to this email directly or view it on GitHub
https://github.com/facebook/fresco/issues/74#issuecomment-146753597.

ssup bro,

I would like more of your tutorials how can i get them.
Regards

On Sat, Oct 10, 2015 at 11:07 AM, christopher pius ndugo <
[email protected]> wrote:

Thanks bro worked perfectly though not using fresco am using picasso.
Regards

On Fri, Oct 9, 2015 at 7:32 AM, andforce [email protected] wrote:

@ManMegh https://github.com/ManMegh @vivian8725118
https://github.com/vivian8725118 You should only call
Fresco.initialize once. Your Application class would be a good place. Doing
it in each Activity is wrong.


Reply to this email directly or view it on GitHub
https://github.com/facebook/fresco/issues/74#issuecomment-146753597.

In my case writing Fresco.initialize(this); before setContentView(R.layout.activity_home); worked

My problem was not specifing the whole path com.facebook.drawee.view.SimpleDraweeView (I had just SimpleDraweeView). IF that is not your case, check the line of XML file on which the error occured.

I have the same problem and none of the solutions above is working for me.

@iDaniel19 paste in your XML

<?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>

I found the problem . I had FacebookSdk.sdkInitialize(this); instead of Fresco.initialize(this);.

@iDaniel19 Glad you solved it. Cheers!

3Q

use following version, and you can initialize fresco in Application class

compile 'com.facebook.fresco:fresco:0.12.0'

facing same issue after updating 1.3.0.

Initialised inside the application class,
Fresco.initialize(this);

Error

FATAL EXCEPTION: main
Process: com.fetchr.driver.android.alpha, PID: 29053
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fetchr.driver.android.alpha/com.fetchr.driver.android.screens.welcome.WelcomeActivity}: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class com.facebook.drawee.view.SimpleDraweeView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class com.facebook.drawee.view.SimpleDraweeView
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.fetchr.driver.android.base.ButterAppCompatActivity.setContentView(ButterAppCompatActivity.java:49)
at com.fetchr.driver.android.screens.welcome.WelcomeActivity.onCreate(WelcomeActivity.java:45)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7225) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class com.facebook.drawee.view.SimpleDraweeView
at android.view.LayoutInflater.createView(LayoutInflater.java:657)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.createCustomViewInternal(CalligraphyLayoutInflater.java:211)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(CalligraphyLayoutInflater.java:20)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(CalligraphyLayoutInflater.java:302)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:192)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:766)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at com.fetchr.driver.android.base.ButterAppCompatActivity.setContentView(ButterAppCompatActivity.java:49) 
at com.fetchr.driver.android.screens.welcome.WelcomeActivity.onCreate(WelcomeActivity.java:45) 
at android.app.Activity.performCreate(Activity.java:6876) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7225) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at android.view.LayoutInflater.createView(LayoutInflater.java:631)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.createCustomViewInternal(CalligraphyLayoutInflater.java:211) 
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.access$000(CalligraphyLayoutInflater.java:20) 
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater$PrivateWrapperFactory2.onCreateView(CalligraphyLayoutInflater.java:302) 
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:192) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:766) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:527) 
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.inflate(CalligraphyLayoutInflater.java:60) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:429) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:380) 
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287) 
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
at com.fetchr.driver.android.base.ButterAppCompatActivity.setContentView(ButterAppCompatActivity.java:49) 
at com.fetchr.driver.android.screens.welcome.WelcomeActivity.onCreate(WelcomeActivity.java:45) 
at android.app.Activity.performCreate(Activity.java:6876) 
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135) 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349) 
at android.app.ActivityThread.access$1100(ActivityThread.java:221) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:158) 
at android.app.ActivityThread.main(ActivityThread.java:7225) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) 
Caused by: java.lang.NumberFormatException: Invalid int: "res/drawable-xxxhdpi-v4/icn_profile_main.png"
at java.lang.Integer.invalidInt(Integer.java:138)
at java.lang.Integer.parse(Integer.java:410)
at java.lang.Integer.parseInt(Integer.java:367)
at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:133)
at android.content.res.TypedArray.getInt(TypedArray.java:357)
at com.facebook.drawee.generic.GenericDraweeHierarchyInflater.updateBuilder(GenericDraweeHierarchyInflater.java:127)
at com.facebook.drawee.generic.GenericDraweeHierarchyInflater.inflateBuilder(GenericDrawee

solved thank you vivian8725118

In my case writing Fresco.initialize(this); before setContentView(R.layout.activity_home); worked

thank you brother , i got the output

Was this page helpful?
0 / 5 - 0 ratings