I am getting a few crash reports with this exception using Fresco version 0.4:
Caused by: java.lang.NullPointerException: SimpleDraweeView was not initialized!
Fresco is initialized very early in my applications onCreate() and I only have this problem with a few selected uses whom I cannot get in touch with.
I'm sorry I can not give you any more information than this. Please close the issue if you can't do anything about this, I just wanted to let you know the problem is out there. I will update this issue if I learn more about it.
Fresco.initialize needs to be called before setContentView in your app.
Hi, I have the same issue. I call Fresco.initialize(context) in my MainActivity. And this error was reported in an Activity which was called later(where I did not call initialize). Do I have to call initialize() and shutdown() in every Activity or do I have to do it only once for the whole application (before setContentView() ofcourse)?
You only need to call initialize once per application. You shouldn't be calling shutdown at all, ordinarily.
I was getting some leaks, probably not from fresco library itself. So I thought of using shutdown(). Are you sure there is no need to call shutdown()?
You should probably sub-class Application if you haven't already, and initialize Fresco in onCreate() of that class.
Yes. I did that now but still there is no way to verify if it solves the issue. AFAIK, the crash only appears on some user's devices. Can anyone explain to me what shutdown() does?
@tyronen what should I do when my app crash and get SimpleDraweeView not initialized error ? Because when my app crash for some reason, the android system recovers the last activity only to find that simpleDraweeView not initialized.
I got the same issue.I have call Fresco.initialize(context) in my Appliaction onCreate.
I have not idea on it.
Caused by: java.lang.NullPointerException: SimpleDraweeView was not initialized!
at com.facebook.common.internal.Preconditions.checkNotNull(Preconditions.java:226)
at com.facebook.drawee.view.SimpleDraweeView.init(SimpleDraweeView.java:79)
at com.facebook.drawee.view.SimpleDraweeView.<init>(SimpleDraweeView.java:61)
I initialized it correctly in the Application's onCreate, Fresco.initialize(context)
I tested exactly same code on 2 devices. one of them Samsung, the other is Piranha, it worked on Pirhana and did not work on Samsung GS3.
The problem was solved when i added the plus:
compile 'com.facebook.fresco:fresco:0.7.0'
in the end, it became like this:
compile 'com.facebook.fresco:fresco:0.7.0+'
then i cleaned, rebuild, re-synched gradle, and restart android studio. it solved the problem!!
so wiered..but worked!
now I added the new version from githuib:
compile 'com.facebook.fresco:fresco:0.8.1+'
Another wierd thing that Developers are updating it on Github and leaving it on the old version on the official website! confusing!
Please fix it both should be the same,
I was having this issue. As it turns out, I had used some of Facebook's sample code in my project, and in their sample code they had Fresco initialize and shutdown for each activity. Removing that stopped my crashes!
@tzveeJ so do the activities open and close smoothly?
@iballan Yes, they do. To clarify, the Facebook sample code contained Fresco.initialize(context) which I have now removed because I had already initialized it in my application class per their instructions.
try {
ImagePipelineConfig config = ImagePipelineConfig.newBuilder(this)
.setDownsampleEnabled(true)
.build();
Fresco.initialize(this, config);
} catch (Exception e) {
e.printStackTrace();
}
the answer like above solved the problem.
Just add Fresco.initialize(this); in your class!
Most helpful comment
Fresco.initialize needs to be called before setContentView in your app.