onGetLayoutInflater throws IllegalStateException: A factory has already been set on this LayoutInflater
See original GitHub issueHello,
I am targeting API 29, using the AndroidX support library. Minimum target is API 19.
Adding this
override fun onGetLayoutInflater(savedInstanceState: Bundle?): LayoutInflater { val wrappedContext = ViewPumpContextWrapper.wrap(Restring.wrapContext(requireContext())) return wrappedContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater }
to my BaseFragment results in the error
java.lang.RuntimeException: Unable to start activity ComponentInfo{******}: java.lang.IllegalStateException: A factory has already been set on this LayoutInflater at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756) Caused by: java.lang.IllegalStateException: A factory has already been set on this LayoutInflater at android.view.LayoutInflater.setFactory(LayoutInflater.java:298) at dev.b3nedikt.viewpump.internal.-ViewPumpLayoutInflater.setFactory(-ViewPumpLayoutInflater.kt:83) at dev.b3nedikt.viewpump.internal.-ViewPumpLayoutInflater.setUpLayoutFactories(-ViewPumpLayoutInflater.kt:76) at dev.b3nedikt.viewpump.internal.-ViewPumpLayoutInflater.<init>(-ViewPumpLayoutInflater.kt:35) at dev.b3nedikt.viewpump.ViewPumpContextWrapper$inflater$2.invoke(ViewPumpContextWrapper.kt:25) at dev.b3nedikt.viewpump.ViewPumpContextWrapper$inflater$2.invoke(ViewPumpContextWrapper.kt:22) at kotlin.UnsafeLazyImpl.getValue(Lazy.kt:81) at dev.b3nedikt.viewpump.ViewPumpContextWrapper.getInflater(ViewPumpContextWrapper.kt) at dev.b3nedikt.viewpump.ViewPumpContextWrapper.getSystemService(ViewPumpContextWrapper.kt:31) at com.shirishanu.apps.ipvc.outgrower.BaseFragment.onGetLayoutInflater(BaseFragment.java:23) at androidx.fragment.app.Fragment.performGetLayoutInflater(Fragment.java:1484) at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:320) at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1187) at androidx.fragment.app.FragmentManager.addAddedFragments(FragmentManager.java:2224) at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1997) at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1953) at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1849) at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2629) at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2577) at androidx.fragment.app.Fragment.performActivityCreated(Fragment.java:2722) at androidx.fragment.app.FragmentStateManager.activityCreated(FragmentStateManager.java:346) at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1188) at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1356) at androidx.fragment.app.FragmentManager.moveFragmentToExpectedState(FragmentManager.java:1434) at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1497) at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2625) at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2577) at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:247) at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:541) at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:210) at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1248) at android.app.Activity.performStart(Activity.java:6679) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2609)
Also I switched to rewword 2.0.1 instead of 2.0.2 because gradle couldn’t find the newer version
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
I updated Reword to 2.0.2, removed Philology and removed the above code as you suggested and everything started to work. Thank you.
@onebird100 The issue with 2.0.2 not getting found is fixed, thanks for reporting 😃