New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A factory has already been set on this LayoutInflater Exception #155
Comments
You are going to have to give more than that. Code examples: How have you included it in your project? What other libs are you using? Are you using custom layout inflators? are you using the latest version of v4/v7 support libs? |
I am using UXCam lib for UX analytics which is also using custom layout inflators. Is it that if another lib sets LayoutInflater.Factory before Calligraphy then this Exception is thrown. my project dependencies are : |
Yeah that won't work you can't batch up layout inflaters. It's meant to do that but without seeing your implementation it's hard to On Thu, 9 Apr 2015 05:08 Bishwash notifications@github.com wrote:
|
we set LayoutInflators in Application.ActivityLifecycleCallbacks : onActivityCreated method . Is there anyway we can prevent crash
|
Why are you not cloneing the current layout inflator and setting the On Fri, 10 Apr 2015 06:52 Bishwash notifications@github.com wrote:
|
This FC now occurs when using a Calligraphy initialized using
|
I switched to AppCompatActivity using appcompat 22.1.0 and started seeing a similar crash. |
I believe I found a work around for the AppCompat 22.1.0 issue. Note, that I haven't tested this on a lot of Android versions; you might have to tweak this if you're targeting Gingerbread.
So you should end up with: public class CustomAppCompatActivity extends FragmentActivity implements AppCompatCallback ... {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getDelegate().onCreate(savedInstanceState);
}
@Override
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
View view = super.onCreateView(parent, name, context, attrs);
if(view != null) {
return view;
}
return getDelegate().createView(parent, name, context, attrs);
}
@Nullable @Override public View onCreateView(String name, Context context, AttributeSet attrs) {
View view = super.onCreateView(name, context, attrs);
if(view != null) {
return view;
}
return getDelegate().createView(null, name, context, attrs);
}
...
} |
I have the same problem with appcompat-v7:22.1.0 |
Same issue :( |
Same with the DrawerLayout and appcompat v22.1.0 |
According to someone on Reddit:
This seems like something the library should handle internally when |
Same crash here |
Sorry guys I'm on holiday so away from a computer. If someone is able to On Wed, 22 Apr 2015 13:36 muresanb notifications@github.com wrote:
|
There is one report from https://github.com/Unpublished that 22.1.1 fixes the issue. It is still reproducing for me, but I just set it up so I can't rule out user error. Can anybody else confirm one way or the other? |
I'm still running into the same error as well even after updating to AppCompat 22.1.1 |
I can confirm that the problem remains with AppCompat 22.1.1 |
Yup, issue still present with 22.1.1. Wonder if its an issue with Calligraphy, or material-dialogs or with the AppCompat itself. |
I'm not too familiar with functionality behind changing the fonts on Calligraphy but leaving a pointer here anyway. It seems so that there's a new interface being introduced within AppCompat 22.1; http://developer.android.com/reference/android/support/v4/view/LayoutInflaterFactory.html Just wondering if not using it relates to these crashes. |
I'll have a dive into this. Thanks for the heads up. On Mon, 27 Apr 2015 at 12:30 Harri Smått notifications@github.com wrote:
|
Not sure is this a proper fix but I noticed setFactory2 gets called multiple times and causes the crash. Though wondering if checking for already existing Factory/Factory2 would do the trick?
As per documentation setting those more than once should cause a crash. |
2.1.0 Snapshot is available with a fix. |
👍 You're the greatest! :-D |
Fixed by #162 |
"You're the greatest!" - Confirmed |
Thank you very much to everybody that help here! 👍 💃 👯 |
I've just got updated to appcompat-v7:22.1.0 and got this error, which has been already solved :) Thanks @chrisjenx |
Thanks, man! |
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.titibots.android.ide.remote/org.modebots.android.ide.ui.MainActivity}: java.lang.IllegalStateException: A factory has already been set on this LayoutInflater
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.IllegalStateException: A factory has already been set on this LayoutInflater
at android.view.LayoutInflater.setFactory(LayoutInflater.java:286)
at uk.co.chrisjenx.calligraphy.CalligraphyLayoutInflater.setFactory(CalligraphyLayoutInflater.java:85)
at android.support.v4.app.Fragment.getLayoutInflater(Fragment.java:935)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:548)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1236)
at android.app.Activity.performStart(Activity.java:6006)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2288)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
The text was updated successfully, but these errors were encountered: