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文件:
<?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"
我在我的清单中找到了: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.
我唯一的问题就是窗帘的问题。我可以做所有其他的事情,比如登录和获取信息。
更多回答
are you using fresco
library?
你在用壁画图书馆吗?
优秀答案推荐
In my case writing Fresco.initialize(this);
before setContentView(R.layout.myxml);
helped me.
在我的例子中,在setContent View(R.layout.myxml)之前编写Fresco.Initialize(This);对我有帮助。
Update:
最新情况:
you have FacebookSdk.sdkInitialize(this);
instead of Fresco.initialize(this)
in your myapplication
您的MyApplication中有FacebookSdk.sdkInitialize(This);,而不是Fresco.Initialize(This
I was getting this problem in API 19 devices just because I was using drawable vector as placeholder here
我在API 19设备中遇到了这个问题,因为我在这里使用了可绘制的矢量作为占位符
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"
Today I had the same problem. However, I forgot to add the property android:name=".MyApplication"
in the AndroidManifest.xml
.
今天我也遇到了同样的问题。但是,我忘了在androidManifest.xml中添加属性android:name=“.MyApplication”。
In your Application class write the following line:
在您的应用程序类中,编写以下行:
Fresco.initialize(this);
Make sure that you import the right Fresco library and if you do import other Fresco libraries, make sure the other libraries version number is the same with Fresco core library
确保导入正确的Fresco库,如果确实导入其他Fresco库,请确保其他库版本号与Fresco核心库相同
In my case writing Fresco.initialize(this);
在我的例子中,编写Fresco.Initialize(This);
before
在此之前
setContentView(R.layout.activity_main);
SetContent View(R.layout.active_main);
更多回答
I tried that too and it isn't working, but now as you can see I have it in MyApplication as suggested in here github.com/facebook/fresco/issues/74
我也试过了,但它不起作用,但正如你现在看到的,我在我的应用程序中有它,如这里所建议的githorb.com/facebook/resco/Issues/74
you have FacebookSdk.sdkInitialize(this);
instead of Fresco.initialize(this)
in you myapplication
您在我的应用程序中拥有FacebookSdk.sdkInitialize(This);而不是Fresco.Initialize(This
Yes, it's working. Should I keep both, or only one ?
是的,它起作用了。我应该两个都留着,还是只留一个?
just Fresco.initialize(this)
is fine
只需Fresco.Initialize(这)就可以了
我是一名优秀的程序员,十分优秀!