App Running On Emulator But not running on phone? - android

When i am trying to install the app on my phone through USB, but it fails to open and the app stops on the splash screen. So i have tried to run the application on the emulator then it is successful and application runs.
I am new to Android unable to debug the error?So, could anyone answer to the following error?
07-04 19:45:48.009 28227-28227/com.example.dell.foodapplication E/HAL: PATH3 /odm/lib64/hw/gralloc.qcom.so
PATH2 /vendor/lib64/hw/gralloc.qcom.so
PATH1 /system/lib64/hw/gralloc.qcom.so
PATH3 /odm/lib64/hw/gralloc.msm8953.so
PATH2 /vendor/lib64/hw/gralloc.msm8953.so
PATH1 /system/lib64/hw/gralloc.msm8953.so
07-04 19:45:52.731 28227-28227/com.example.dell.foodapplication E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.dell.foodapplication, PID: 28227
java.lang.OutOfMemoryError: Failed to allocate a 298598412 byte allocation with 14026592 free bytes and 171MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:624)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:457)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1152)
at android.content.res.ResourcesImpl.createFromResourceStream(ResourcesImpl.java:1272)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:743)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:585)
at android.content.res.MiuiResourcesImpl.loadDrawable(MiuiResourcesImpl.java:308)
at android.content.res.Resources.loadDrawable(Resources.java:872)
at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
at android.widget.ImageView.<init>(ImageView.java:157)
at android.widget.ImageView.<init>(ImageView.java:145)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:72)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:68)
at android.support.v7.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:182)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
at android.support.v7.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1263)
at android.support.v7.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1313)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:192)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:752)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:883)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.parseInclude(LayoutInflater.java:1019)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:879)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.inflate(LayoutInflater.java:522)
at android.view.LayoutInflater.inflate(LayoutInflater.java:430)
at com.example.dell.foodapplication.SelectFragment.onCreateView(SelectFragment.java:38)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2425)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:802)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2623)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2410)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2365)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2242)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:654)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:146)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1244)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1092)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1622)
at android.view.View.measure(View.java:19759)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
at android.view.View.measure(View.java:19759)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143)
at android.view.View.measure(View.java:19759)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
at android.view.View.measure(View.java:19759)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:19759)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
at android.view.View.measure(View.java:19759)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6122)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:690)
at android.view.View.measure(View.java:19759)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2308)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1395)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1644)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1283)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6354)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:873)
at android.view.Choreographer.doCallbacks(Choreographer.java:685)
at android.view.Choreographer.doFrame(Choreographer.java:621)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:859)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6342)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)

Sourav Mund check the size of the drawable food_logo and let's know the size i'm guessing your OOM is coming from there

Related

java.lang.ClassCastException when trying to add constraints to textview

I'm programmatically creating a constraint layout and adding a text view to it, but when I try to add the constraints it raises a java.lang.ClassCastException exception. Here is my code:
var textlayoutbottom = ConstraintLayout(this)
textlayout.addView(textlayoutbottom)
var typelabel = TextView(this)
textlayoutbottom.addView(typelabel)
textlayoutbottom.layoutParams = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)
typelabel.text = getAnimeType(anime.type)
var params = typelabel.layoutParams as ConstraintLayout.LayoutParams
params.leftToLeft = textlayoutbottom.id
params.bottomToBottom = textlayoutbottom.id
typelabel.requestLayout()
But the app crashes and it doesn't even show the error line.
Here is my log:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.my.package, PID: 5234
java.lang.ClassCastException: androidx.constraintlayout.widget.ConstraintLayout$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams
at android.widget.LinearLayout.measureVertical(LinearLayout.java:731)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
at android.view.View.measure(View.java:19857)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1117)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:642)
at android.view.View.measure(View.java:19857)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
at android.view.View.measure(View.java:19857)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
at android.view.View.measure(View.java:19857)
at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1293)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.widget.ScrollView.onMeasure(ScrollView.java:340)
at android.view.View.measure(View.java:19857)
at androidx.constraintlayout.widget.ConstraintLayout$Measurer.measure(ConstraintLayout.java:792)
at androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:583)
at androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer.layout(ConstraintWidgetContainer.java:682)
at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.solveLinearSystem(BasicMeasure.java:159)
at androidx.constraintlayout.solver.widgets.analyzer.BasicMeasure.solverMeasure(BasicMeasure.java:290)
at androidx.constraintlayout.solver.widgets.ConstraintWidgetContainer.measure(ConstraintWidgetContainer.java:119)
at androidx.constraintlayout.widget.ConstraintLayout.resolveSystem(ConstraintLayout.java:1578)
at androidx.constraintlayout.widget.ConstraintLayout.onMeasure(ConstraintLayout.java:1690)
at android.view.View.measure(View.java:19857)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:146)
at android.view.View.measure(View.java:19857)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
at android.view.View.measure(View.java:19857)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:19857)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
at android.view.View.measure(View.java:19857)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:689)
at android.view.View.measure(View.java:19857)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2275)
E/AndroidRuntime: at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1366)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1619)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
at android.view.Choreographer.doCallbacks(Choreographer.java:686)
at android.view.Choreographer.doFrame(Choreographer.java:621)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Any ideas?
Hey you are setting ConstraintLayout.LayoutParams to ConstraintLayout itself, try setting it to TextView and for textlayoutbottom use LinearLayout.LayoutParams
textlayoutbottom.layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT) //for constraint layout
typeLabel.layoutParams = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT)//for typeLabel

ScrollView.layoutParam is returning Framelayout.layoutParam

I'm trying to set margin dynamically for a scroll view,
Surprisingly, my code is returning FrameLayout.layoutParam instead of ScrollView.LayoutParam here is my code, which is causing Class Cast Exception
ScrollView.LayoutParams scrollViewParam = new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT, ScrollView.LayoutParams.MATCH_PARENT);
scrollViewParam.setMargins(0, 0, 0, 500);
scrollView.setLayoutParams(scrollViewParam);
here is the stacktrace
java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast to android.support.constraint.ConstraintLayout$LayoutParams
at android.support.constraint.ConstraintLayout.getViewWidget(ConstraintLayout.java:877)
at android.support.constraint.ConstraintLayout.setChildrenConstraints(ConstraintLayout.java:643)
at android.support.constraint.ConstraintLayout.updateHierarchy(ConstraintLayout.java:631)
at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:971)
at android.view.View.measure(View.java:22071)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:141)
at android.view.View.measure(View.java:22071)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:22071)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:22071)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
at android.view.View.measure(View.java:22071)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:724)
at android.view.View.measure(View.java:22071)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2422)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1504)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1761)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1392)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6752)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:723)
at android.view.Choreographer.doFrame(Choreographer.java:658)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
So, What is wrong with my code?
Every view has layout params associated with it's parent ViewGroup.
In your case, your ScrollView must live inside a ConstraintLayout (or a subclass of it). So, when you try to set it's layout params, it'll be expending an instance of a ConstraintLayout.LayoutParams.
Change your code with this and it should work just fine:
ConstraintLayout.LayoutParams scrollViewParam = new ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT, ConstraintLayout.LayoutParams.MATCH_PARENT);
scrollViewParam.setMargins(0, 0, 0, 500);
scrollView.setLayoutParams(scrollViewParam);

Android: getting IllegalAccessError only on built APKs

So I'm getting this error only when I'm running the APK and app crashes immediately. (no matter signed, unsigned release mode or debug)
but when I run the app from android studio, everything's fine.
I have both kotlin and java files in the project.
and the error is caused by a kotlin file by the way.
any idea ?
here's the error log:
java.lang.IllegalAccessError: com.app.myapp.fragment.HomeFragment$onViewCreated$1
at com.app.myapp.fragment.HomeFragment.onViewCreated(HomeFragment.kt:155)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1430)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2199)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:651)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:145)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1236)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1084)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1614)
at android.view.View.measure(View.java:20221)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:716)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:462)
at android.view.View.measure(View.java:20221)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1630)
at android.view.View.measure(View.java:20221)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:716)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:462)
at android.view.View.measure(View.java:20221)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
at android.view.View.measure(View.java:20221)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:747)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
at android.view.View.measure(View.java:20221)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at android.view.View.measure(View.java:20221)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:747)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:629)
at android.view.View.measure(View.java:20221)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6333)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:194)
at com.android.internal.policy.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:3140)
at android.view.View.measure(View.java:20221)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2687)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1640)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1932)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1528)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7530)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
at android.view.Choreographer.doCallbacks(Choreographer.java:686)
at android.view.Choreographer.doFrame(Choreographer.java:622)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMess
and here's the onViewCreated method:
override fun onViewCreated(view: View?, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
adapter = MyAdapter(list)
adapter!!.addOnItemClickListener { pos , Data->
...
}
}
there's an interface in recyclerView's adapter which passes data on each item Click. once again, this code works on debug mode and I used this structure a lot in other java classes.
any help would be appreciated. This thing is driving me crazy !

Failed to load WebView provider: No WebView installed [duplicate]

Recently, we've started seeing this new entry in our crashlytics which says that android can't find the webview package on the device.
Here's the full stacktrace (classes from our source code have been replaced with ..... :
Fatal Exception: android.view.InflateException: Binary XML file line #139: Binary XML file line #139: Error inflating class <unknown>
Caused by android.view.InflateException: Binary XML file line #139: Error inflating class <unknown>
Caused by java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at g.a.a.a.d.a(SourceFile:211)
at g.a.a.a.d.a(SourceFile:20)
at g.a.a.a.d$a.onCreateView(SourceFile:302)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:777)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at g.a.a.a.d.inflate(SourceFile:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at ......(SourceFile:148)
at ......(SourceFile:119)
at ......(SourceFile:28)
at android.support.v4.view.ViewPager.a(SourceFile:1034)
at android.support.v4.view.ViewPager.a(SourceFile:1182)
at android.support.v4.view.ViewPager.c(SourceFile:1116)
at android.support.v4.view.ViewPager.onMeasure(SourceFile:1642)
at ....(SourceFile:27)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
at android.view.View.measure(View.java:20234)
at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1320)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at android.widget.ScrollView.onMeasure(ScrollView.java:345)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
at android.view.View.measure(View.java:20234)
at android.support.v4.view.ViewPager.onMeasure(SourceFile:1658)
at android.view.View.measure(View.java:20234)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:825)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:511)
at android.view.View.measure(View.java:20234)
at android.support.v4.widget.DrawerLayout.onMeasure(SourceFile:1081)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at android.support.v7.widget.ContentFrameLayout.onMeasure(SourceFile:139)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:716)
at android.view.View.measure(View.java:20234)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2659)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1600)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1873)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1485)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7078)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:910)
at android.view.Choreographer.doCallbacks(Choreographer.java:712)
at android.view.Choreographer.doFrame(Choreographer.java:646)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:896)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6369)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1088)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:949)
Caused by android.util.AndroidRuntimeException: android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed
at android.webkit.WebViewFactory.getProviderClass(WebViewFactory.java:395)
at android.webkit.WebViewFactory.getProvider(WebViewFactory.java:194)
at android.webkit.WebView.getFactory(WebView.java:2592)
at android.webkit.WebView.findAddress(WebView.java:1958)
at android.text.util.Linkify.gatherMapLinks(Linkify.java:599)
at android.text.util.Linkify.addLinks(Linkify.java:287)
at android.widget.TextView.setText(TextView.java:4474)
at android.widget.TextView.setText(TextView.java:4395)
at android.widget.TextView.<init>(TextView.java:1472)
at android.widget.TextView.<init>(TextView.java:727)
at android.widget.TextView.<init>(TextView.java:723)
at me.grantland.widget.AutofitTextView.<init>(SourceFile:25)
at java.lang.reflect.Constructor.newInstance0(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at g.a.a.a.d.a(SourceFile:211)
at g.a.a.a.d.a(SourceFile:20)
at g.a.a.a.d$a.onCreateView(SourceFile:302)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:777)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at g.a.a.a.d.inflate(SourceFile:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at ....(SourceFile:148)
at ....(SourceFile:119)
at ....(SourceFile:28)
at android.support.v4.view.ViewPager.a(SourceFile:1034)
at android.support.v4.view.ViewPager.a(SourceFile:1182)
at android.support.v4.view.ViewPager.c(SourceFile:1116)
at android.support.v4.view.ViewPager.onMeasure(SourceFile:1642)
at ....(SourceFile:27)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
at android.view.View.measure(View.java:20234)
at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1320)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at android.widget.ScrollView.onMeasure(ScrollView.java:345)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
at android.view.View.measure(View.java:20234)
at android.support.v4.view.ViewPager.onMeasure(SourceFile:1658)
at android.view.View.measure(View.java:20234)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:825)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:511)
at android.view.View.measure(View.java:20234)
at android.support.v4.widget.DrawerLayout.onMeasure(SourceFile:1081)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at android.support.v7.widget.ContentFrameLayout.onMeasure(SourceFile:139)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:716)
at android.view.View.measure(View.java:20234)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2659)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1600)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1873)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1485)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7078)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:910)
at android.view.Choreographer.doCallbacks(Choreographer.java:712)
at android.view.Choreographer.doFrame(Choreographer.java:646)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:896)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6369)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1088)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:949)
Caused by android.webkit.WebViewFactory$MissingWebViewPackageException: Failed to load WebView provider: No WebView installed
at android.webkit.WebViewFactory.getWebViewContextAndSetProvider(WebViewFactory.java:294)
at android.webkit.WebViewFactory.getProviderClass(WebViewFactory.java:354)
at android.webkit.WebViewFactory.getProvider(WebViewFactory.java:194)
at android.webkit.WebView.getFactory(WebView.java:2592)
at android.webkit.WebView.findAddress(WebView.java:1958)
at android.text.util.Linkify.gatherMapLinks(Linkify.java:599)
at android.text.util.Linkify.addLinks(Linkify.java:287)
at android.widget.TextView.setText(TextView.java:4474)
at android.widget.TextView.setText(TextView.java:4395)
at android.widget.TextView.<init>(TextView.java:1472)
at android.widget.TextView.<init>(TextView.java:727)
at android.widget.TextView.<init>(TextView.java:723)
at me.grantland.widget.AutofitTextView.<init>(SourceFile:25)
at java.lang.reflect.Constructor.newInstance0(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at g.a.a.a.d.a(SourceFile:211)
at g.a.a.a.d.a(SourceFile:20)
at g.a.a.a.d$a.onCreateView(SourceFile:302)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:777)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:858)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:861)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at g.a.a.a.d.inflate(SourceFile:60)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at ....(SourceFile:148)
at ....(SourceFile:119)
at ....(SourceFile:28)
at android.support.v4.view.ViewPager.a(SourceFile:1034)
at android.support.v4.view.ViewPager.a(SourceFile:1182)
at android.support.v4.view.ViewPager.c(SourceFile:1116)
at android.support.v4.view.ViewPager.onMeasure(SourceFile:1642)
at ....(SourceFile:27)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
at android.view.View.measure(View.java:20234)
at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1320)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at android.widget.ScrollView.onMeasure(ScrollView.java:345)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
at android.view.View.measure(View.java:20234)
at android.support.v4.view.ViewPager.onMeasure(SourceFile:1658)
at android.view.View.measure(View.java:20234)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:825)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:511)
at android.view.View.measure(View.java:20234)
at android.support.v4.widget.DrawerLayout.onMeasure(SourceFile:1081)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at android.support.v7.widget.ContentFrameLayout.onMeasure(SourceFile:139)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1705)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:797)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:657)
at android.view.View.measure(View.java:20234)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6249)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:716)
at android.view.View.measure(View.java:20234)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2659)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1600)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1873)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1485)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7078)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:910)
at android.view.Choreographer.doCallbacks(Choreographer.java:712)
at android.view.Choreographer.doFrame(Choreographer.java:646)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:896)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6369)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1088)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:949)
We are seeing this on :
Android versions : 5,6,7
Devices Manufacturers: Lenovo, oneplus, samsung, motorola
And, the devices are not rooted.
After searching for a while, I am not able to find any appropriate cause (and handling) for this. Went through this question also but it doesn't have any solution.
Please help.
Edit : This is happening for a lot of our users, so I can't go and tell everyone to check/install webiew from the play store.
Is there a better solution for this?
I figured out a probable problem here. As we know that webview has been shipping as a separate app from android 5.0, it may be the case that at the time my view is being inflated, the webview package is being updated by the os and therefore it can't find the webview pacakge for those few moments. I know it's a very borderline case but
as I can see, the crash is happening on only >= 5.0 devices which support this hypothesis
it's very hard to believe that all such devices don't have webview installed. As a matter of fact, I tried uninstalling the system and chrome packages from my device but still the app doesn't crash.
So here's what I did (hacky solution but prevents crashes):
try {
// the inflating code that's causing the crash
} catch (Exception e) {
if (e.getMessage() != null && e.getMessage().contains("webview")) {
// If the system failed to inflate this view because of the WebView (which could
// be one of several types of exceptions), it likely means that the system WebView
// is either not present (unlikely) OR in the process of being updated (also unlikely).
// It's unlikely but we have been receiving a lot of crashes.
// In this case, show the user a message and finish the activity
}
}
Basically nothing but handling that exception. No rocket science there.
I faced the same issue in Android 12. I opened the Android System Webiew in my Play Store app and uninstalled it. After it was uninstalled I enabled it by clicking on the Enable button. That worked for me.
Please refer to this issue.
Workaround
try {
super.setText(spannableStringBuilder, type);
} catch (Exception e) {
// WebView is not installed in some devices by default, Linkify.MAP_ADDRESSES causes the exception
if (e.getMessage().contains("webview")){
setAutoLinkMask(Linkify.WEB_URLS | Linkify.EMAIL_ADDRESSES | Linkify.PHONE_NUMBERS);
}
super.setText(spannableStringBuilder, type);
}
My exception is
android.webkit.WebViewFactory$MissingWebViewPackageException
Failed to load WebView provider: No WebView installed
detail stack is:
java.lang.RuntimeException:Unable to start activity ComponentInfo{cn.trinea.android.developertools/a.a.aa}: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class a.a.ab
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
......
android.webkit.WebViewFactory$MissingWebViewPackageException:Failed to load WebView provider: No WebView installed
android.webkit.WebViewFactory.getWebViewContextAndSetProvider(WebViewFactory.java:270)
android.webkit.WebViewFactory.getProviderClass(WebViewFactory.java:330)
android.webkit.WebViewFactory.getProvider(WebViewFactory.java:194)
android.webkit.WebView.getFactory(WebView.java:2325)
android.webkit.WebView.ensureProviderCreated(WebView.java:2320)
android.webkit.WebView.setOverScrollMode(WebView.java:2379)
android.view.View.<init>(View.java:4023)
android.view.View.<init>(View.java:4146)
android.view.ViewGroup.<init>(ViewGroup.java:579)
android.widget.AbsoluteLayout.<init>(AbsoluteLayout.java:55)
android.webkit.WebView.<init>(WebView.java:627)
android.webkit.WebView.<init>(WebView.java:572)
android.webkit.WebView.<init>(WebView.java:555)
android.webkit.WebView.<init>(WebView.java:542)
solution is
public class MyWebView extends WebView {
#Override
public void setOverScrollMode(int mode) {
try {
super.setOverScrollMode(mode);
} catch (Exception e) {
if (e.getMessage() != null && e.getMessage().contains("Failed to load WebView provider: No WebView installed")) {
e.printStackTrace();
} else {
throw e;
}
}
}
}
According to the TextView's sourceCode
if (mAutoLinkMask != 0) {
...
if (Linkify.addLinks(s2, mAutoLinkMask)) {
...
}
}
The textview with android:autoLink property will call Linkify.addLinks (reaches the method of WebView finally) and cause the crash.
So, we can remove the android:autoLink property and realize with other way to fix the problem.

FragmentManager throws IllegalArgumentException in Kotlin

I have the following method in my Fragment
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
val fm = childFragmentManager
var prefsFragment: PrefsFragment? = fm.findFragmentByTag(tableName) as PrefsFragment?
if (prefsFragment == null) {
prefsFragment = PrefsFragment()
val ft = fm.beginTransaction()
ft.add(R.id.parameters_fragment_container, prefsFragment, tableName)
ft.commit()
fm.executePendingTransactions()
}
}
I have to say this is what the Java->Kotlin automagic translator did with my previous Java code (save for the ? at the end of the line where I find the PrefsFragment by tag), so it may not be entirely kosher. I'm learning Kotlin by doing.
Now, when I call executePendingTransactions(), my app crashes throwing java.lang.IllegalArgumentException with error message "Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter savedInstanceState". Now, yes, savedInstanceState is in fact null, but what does it have to do with the call that apparently throws the exception? I made sure that no other values/variables are null, so I'd trust the error message... but why?
EDIT Here is the stack trace, and the source code that's giving me nightmares
https://gist.github.com/Morpheu5/8ec7e2064f53679405769b43c64f2cb7
E/AndroidRuntime: FATAL EXCEPTION: main
Process: net.morpheu5.bleedingscorecalculator, PID: 2685
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter savedInstanceState
at net.morpheu5.bleedingscorecalculator.CalculatorScreen$PrefsFragment.onCreatePreferences(CalculatorScreen.kt:0)
at android.support.v7.preference.PreferenceFragmentCompat.onCreate(PreferenceFragmentCompat.java:223)
at android.support.v4.app.Fragment.performCreate(Fragment.java:2075)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1060)
at android.support.v4.app.BackStackRecord.setLastIn(BackStackRecord.java:838)
at android.support.v4.app.BackStackRecord.calculateFragments(BackStackRecord.java:861)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:719)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1682)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:594)
at net.morpheu5.bleedingscorecalculator.CalculatorScreen.onActivityCreated(CalculatorScreen.kt:34)
at android.support.v4.app.Fragment.performActivityCreated(Fragment.java:2096)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1295)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:801)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:1643)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:679)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:143)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1272)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1120)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1646)
at android.view.View.measure(View.java:19857)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:703)
at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:90)
at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1367)
at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:768)
at android.view.View.measure(View.java:19857)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
at android.view.View.measure(View.java:19857)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
at android.view.View.measure(View.java:19857)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at android.view.View.measure(View.java:19857)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
at android.view.View.measure(View.java:19857)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:689)
at android.view.View.measure(View.java:19857)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2275)
E/AndroidRuntime: at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1366)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1619)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
at android.view.Choreographer.doCallbacks(Choreographer.java:686)
at android.view.Choreographer.doFrame(Choreographer.java:621)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6119)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
The exception isn't actually coming from that code. It is coming from your CalculatorScreen.PrefsFragment.onCreatePreferences() method. If you look there, it looks like --
override fun onCreatePreferences(savedInstanceState: Bundle, rootKey : String)
and it should be the following to allow savedInstanceState to be null --
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey : String)

Categories

Resources