ImageView in Listview throwing Exception in Android - android

I am trying to include the list view in tabs layout which include two texts and a image view. but it is giving following log cat. There are three tabs in my app out of which I am trying to include the listview in second and third tab. The second tab was working earlier but as I pasted the same code for the third tab with some changes it is showing following erroe The last return statement of the tab is throwing exception .I searched for similar questions but didn't got the answer. I am new at android development .
StackTrace log
Process: com.example.shubham.tabexample, PID: 32353
android.view.InflateException: Binary XML file line #56: Binary XML file line #56: Error inflating class ImageView
Caused by: android.view.InflateException: Binary XML file line #56: Error inflating class ImageView
Caused by: android.content.res.Resources$NotFoundException: Drawable com.example.shubham.tabexample:id/imgview with resource ID #0x7f0e0094
Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.shubham.tabexample:id/imgview" (7f0e0094) is not a Drawable (color or path): TypedValue{t=0x12/d=0x0 a=3 r=0x7f0e0094}
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:691)
at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:575)
at android.content.res.Resources.loadDrawable(Resources.java:972)
at android.content.res.TypedArray.getDrawable(TypedArray.java:931)
at android.widget.ImageView.<init>(ImageView.java:167)
at android.widget.ImageView.<init>(ImageView.java:155)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:60)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:56)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1026)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1083)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:192)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)
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.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at com.example.shubham.JeevanSathi.Activity.Tab2.onCreateView(Tab2.java:28)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2239)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1332)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1574)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1641)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:794)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2415)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2200)
at android.support.v4.app.FragmentManagerImpl.optimizeAndExecuteOps(FragmentManager.java:2153)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2034)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:651)
at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:166)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1239)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1087)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1613)
at android.view.View.measure(View.java:20110)
at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:825)
at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:511)
at android.view.View.measure(View.java:20110)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6286)
at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:713)
07-29 13:10:38.399 32353-32353/com.example.shubham.tabexample E/AndroidRuntime: at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:785)
at android.view.View.measure(View.java:20110)
at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1080)
at android.view.View.measure(View.java:20110)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6286)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
at android.view.View.measure(View.java:20110)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6286)
at android.support.v7.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:391)
at android.view.View.measure(View.java:20110)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6286)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at android.view.View.measure(View.java:20110)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6286)
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:20110)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6286)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:214)
at com.android.internal.policy.DecorView.onMeasure(DecorView.java:714)
at android.view.View.measure(View.java:20110)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2649)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1586)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1855)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1471)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7009)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:907)
at android.view.Choreographer.doCallbacks(Choreographer.java:709)
at android.view.Choreographer.doFrame(Choreographer.java:644)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:893)
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:6293)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1065)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:926)
Tab2.java
package com.example.shubham.JeevanSathi.Activity;
/**
* Created by Shubham on 7/25/2017.
*/
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.shubham.JeevanSathi.R;
//Our class extending fragment
public class Tab2 extends Fragment {
//Overriden method onCreateView
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//Returning the layout file after inflating
//Change R.layout.tab1 in you classes
return inflater.inflate(R.layout.tab2, container, false);
}
}

Check your drawable file if it is available then clean the code and build it. If it will not help post the xml file here

Related

Android TV player inflating error on PlaybackTransportRowPresenter.createRowViewHolder

I wrote bellow code in fragment that extends 'VideoSupportFragment'
val playerGlue = PlaybackTransportControlGlue(
activity,
MediaPlayerAdapter(activity))
playerGlue.setHost(VideoSupportFragmentGlueHost(this))
playerGlue.addPlayerCallback(object : PlaybackGlue.PlayerCallback() {
override fun onPreparedStateChanged(glue: PlaybackGlue) {
if (glue.isPrepared()) {
//playerGlue.seekProvider = MySeekProvider()
playerGlue.play()
}
}
})
playerGlue.playerAdapter?.setDataSource(Uri.parse("http://techslides.com/demos/sample-videos/small.mp4"))
When setHost is called app crashes and bellow log appears in logcat.
If i comment setHost, just audio get play.
2020-03-15 02:32:15.578 1779-1779/tv.debug E/AndroidRuntime: FATAL EXCEPTION: main
Process: tv.debug, PID: 1779
android.view.InflateException: Binary XML file line #33: Binary XML file line #33: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #33: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:645)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)
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.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at androidx.leanback.widget.PlaybackTransportRowPresenter.createRowViewHolder(PlaybackTransportRowPresenter.java:684)
at androidx.leanback.widget.RowPresenter.onCreateViewHolder(RowPresenter.java:326)
at androidx.leanback.widget.ItemBridgeAdapter.onCreateViewHolder(ItemBridgeAdapter.java:352)
at androidx.recyclerview.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:7078)
at androidx.recyclerview.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:6235)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6118)
at androidx.recyclerview.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:6114)
at androidx.leanback.widget.GridLayoutManager.getViewForPosition(GridLayoutManager.java:1085)
at androidx.leanback.widget.GridLayoutManager$2.createItem(GridLayoutManager.java:1613)
at androidx.leanback.widget.SingleRow.appendVisibleItems(SingleRow.java:113)
at androidx.leanback.widget.Grid.appendOneColumnVisibleItems(Grid.java:389)
at androidx.leanback.widget.GridLayoutManager.appendOneColumnVisibleItems(GridLayoutManager.java:1839)
at androidx.leanback.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:2276)
at androidx.recyclerview.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:4134)
at androidx.recyclerview.widget.RecyclerView.dispatchLayout(RecyclerView.java:3851)
at androidx.recyclerview.widget.RecyclerView.consumePendingUpdateOperations(RecyclerView.java:1897)
at androidx.recyclerview.widget.RecyclerView$1.run(RecyclerView.java:414)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
at android.view.Choreographer.doCallbacks(Choreographer.java:686)
at android.view.Choreographer.doFrame(Choreographer.java:618)
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)
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 68: TypedValue{t=0x2/d=0x7f04005d a=-1}
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:716)
at android.view.View.<init>(View.java:4228)
at android.view.ViewGroup.<init>(ViewGroup.java:579)
at android.widget.LinearLayout.<init>(LinearLayout.java:211)
at android.widget.LinearLayout.<init>(LinearLayout.java:207)
2020-03-15 02:32:15.578 1779-1779/com.shatelland.namava.tv.debug E/AndroidRuntime: at android.widget.LinearLayout.<init>(LinearLayout.java:203)
I don't know why the class is unknown.
i can't find which layout has error because of this.
After long time searching i find the reason.
The Activity that contains the Fragment should set theme to Leanback
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setTheme(R.style.Theme_Leanback)
}

How to fix crash on only Huawei devices in android.widget.SearchView

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.***.***/com.***.***.activities.SearchActivity}: android.view.InflateException: Binary XML file line #29: Binary XML file line #29: Error inflating class android.widget.SearchView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2451)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2511)
at android.app.ActivityThread.access$900(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1375)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5621)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
Caused by java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at android.view.LayoutInflater.createView(LayoutInflater.java:638)
at com.mikepenz.iconics.context.InternalLayoutInflater.onCreateView(InternalLayoutInflater.java:54)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:713)
at com.mikepenz.iconics.context.InternalLayoutInflater.onCreateView(InternalLayoutInflater.java:70)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:781)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:723)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:817)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:857)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:817)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at com.mikepenz.iconics.context.InternalLayoutInflater.inflate(InternalLayoutInflater.java:81)
at android.view.LayoutInflater.inflate(LayoutInflater.java:434)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.***.***.activities.SearchActivity.onCreate(SearchActivity.java:124)
at android.app.Activity.performCreate(Activity.java:6367)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2404)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2511)
at android.app.ActivityThread.access$900(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1375)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5621)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
Caused by android.view.InflateException: Binary XML file line #79: Binary XML file line #79: Error inflating class android.widget.SearchView$SearchAutoComplete
at android.view.LayoutInflater.inflate(LayoutInflater.java:558)
at com.mikepenz.iconics.context.InternalLayoutInflater.inflate(InternalLayoutInflater.java:81)
at android.view.LayoutInflater.inflate(LayoutInflater.java:434)
at android.widget.SearchView.inflateSearchView(SearchView.java:1847)
at android.widget.SearchView.(SearchView.java:268)
at android.widget.SearchView.(SearchView.java:259)
at android.widget.SearchView.(SearchView.java:255)
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at android.view.LayoutInflater.createView(LayoutInflater.java:638)
at com.mikepenz.iconics.context.InternalLayoutInflater.onCreateView(InternalLayoutInflater.java:54)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:713)
at com.mikepenz.iconics.context.InternalLayoutInflater.onCreateView(InternalLayoutInflater.java:70)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:781)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:723)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:817)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:857)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:817)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at com.mikepenz.iconics.context.InternalLayoutInflater.inflate(InternalLayoutInflater.java:81)
at android.view.LayoutInflater.inflate(LayoutInflater.java:434)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.***.***.activities.SearchActivity.onCreate(SearchActivity.java:124)
at android.app.Activity.performCreate(Activity.java:6367)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2404)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2511)
at android.app.ActivityThread.access$900(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1375)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5621)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
Caused by android.view.InflateException: Binary XML file line #79: Error inflating class android.widget.SearchView$SearchAutoComplete
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:801)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:723)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:817)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:857)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:817)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:857)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:817)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at com.mikepenz.iconics.context.InternalLayoutInflater.inflate(InternalLayoutInflater.java:81)
at android.view.LayoutInflater.inflate(LayoutInflater.java:434)
at android.widget.SearchView.inflateSearchView(SearchView.java:1847)
at android.widget.SearchView.(SearchView.java:268)
at android.widget.SearchView.(SearchView.java:259)
at android.widget.SearchView.(SearchView.java:255)
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at android.view.LayoutInflater.createView(LayoutInflater.java:638)
at com.mikepenz.iconics.context.InternalLayoutInflater.onCreateView(InternalLayoutInflater.java:54)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:713)
at com.mikepenz.iconics.context.InternalLayoutInflater.onCreateView(InternalLayoutInflater.java:70)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:781)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:723)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:817)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:857)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:817)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at com.mikepenz.iconics.context.InternalLayoutInflater.inflate(InternalLayoutInflater.java:81)
at android.view.LayoutInflater.inflate(LayoutInflater.java:434)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.***.***.activities.SearchActivity.onCreate(SearchActivity.java:124)
at android.app.Activity.performCreate(Activity.java:6367)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2404)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2511)
at android.app.ActivityThread.access$900(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1375)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5621)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
Caused by java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.widget.SearchView.isInActionMode()' on a null object reference
at android.widget.SearchView$SearchAutoComplete.enoughToFilter(SearchView.java:1801)
at android.widget.AutoCompleteTextView.doAfterTextChanged(AutoCompleteTextView.java:781)
at android.widget.AutoCompleteTextView$MyWatcher.afterTextChanged(AutoCompleteTextView.java:749)
at android.widget.TextView.sendAfterTextChanged(TextView.java:8232)
at android.widget.TextView.setText(TextView.java:4435)
at android.widget.TextView.setText(TextView.java:4283)
at android.widget.EditText.setText(EditText.java:84)
at android.widget.TextView.setText(TextView.java:4258)
at com.mikepenz.iconics.Iconics$IconicsBuilderView.build(Iconics.java:297)
at com.mikepenz.iconics.context.IconicsFactory.onViewCreatedInternal(IconicsFactory.java:50)
at com.mikepenz.iconics.context.IconicsFactory.onViewCreated(IconicsFactory.java:27)
at com.mikepenz.iconics.context.InternalLayoutInflater$PrivateWrapperFactory2.onCreateView(InternalLayoutInflater.java:245)
at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:189)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:773)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:723)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:817)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:857)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:817)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:857)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:817)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at com.mikepenz.iconics.context.InternalLayoutInflater.inflate(InternalLayoutInflater.java:81)
at android.view.LayoutInflater.inflate(LayoutInflater.java:434)
at android.widget.SearchView.inflateSearchView(SearchView.java:1847)
at android.widget.SearchView.(SearchView.java:268)
at android.widget.SearchView.(SearchView.java:259)
at android.widget.SearchView.(SearchView.java:255)
at java.lang.reflect.Constructor.newInstance(Constructor.java)
at android.view.LayoutInflater.createView(LayoutInflater.java:638)
at com.mikepenz.iconics.context.InternalLayoutInflater.onCreateView(InternalLayoutInflater.java:54)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:713)
at com.mikepenz.iconics.context.InternalLayoutInflater.onCreateView(InternalLayoutInflater.java:70)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:781)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:723)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:854)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:817)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:857)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:817)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at com.mikepenz.iconics.context.InternalLayoutInflater.inflate(InternalLayoutInflater.java:81)
at android.view.LayoutInflater.inflate(LayoutInflater.java:434)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.***.***.activities.SearchActivity.onCreate(SearchActivity.java:124)
at android.app.Activity.performCreate(Activity.java:6367)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2404)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2511)
at android.app.ActivityThread.access$900(ActivityThread.java:165)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1375)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:150)
at android.app.ActivityThread.main(ActivityThread.java:5621)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:794)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:684)
According to the log its happening in the oncreate of activity when trying to inflate the searchview. I am using 'android.widget.SearchView' instead of appcompat because I am animating it and can't get the appcompat version to animate properly.
I do not feel this is an animate issue though. I cannot figure out why its only happening on Huawei devices. I released this update last week and its already on 100k plus devices. According to Crashlytics its 100% Huawei and 81% Android 8, 15% Android 7 and 4% Android 6.
I have tried try/catches on the start activity, on create and few other places but nothing catches it. I can post code if needed but wanted to see if it was necessary.
Here is the searchview in the layout
<SearchView
android:id="#+id/search_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"
android:iconifiedByDefault="false"/>
And this is initializing the searchview in oncreate
SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
if (searchManager != null) {
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
}
Setting setSearchableInfo is calling updateSearchAutoComplete() which is where the crash starts. But i have tried a try/catch there an still crashes.

Runtime Exception in Preference Fragment

I have a preference fragment with the following files
preference.xml
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<EditTextPreference
android:defaultValue="0000"
android:key="#string/pin"
android:summary="Set Pin for Notes"
android:title="Password" />
</PreferenceScreen>
Preference Activity
public class PreferenceActivity extends AppCompatActivity {
#BindView(R.id.toolbar_settings)
Toolbar toolbarSettings;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
ButterKnife.bind(this);
setSupportActionBar(toolbarSettings);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
}
and finally
Preference Fragment
public class PreferenceFragment extends PreferenceFragmentCompat {
#Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
addPreferencesFromResource(R.xml.preference);
}
}
But here when the addPreferencesFromResources is called, I am getting a runtime exception.
Here is the log stack
Exception
02-21 22:23:36.574 8813-8813/in.snotes.snotes E/AndroidRuntime: FATAL EXCEPTION: main
Process: in.snotes.snotes, PID: 8813
java.lang.RuntimeException: Unable to start activity ComponentInfo{in.snotes.snotes/in.snotes.snotes.settings.PreferenceActivity}: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
Caused by: android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class fragment
Caused by: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
at android.app.SharedPreferencesImpl.getString(SharedPreferencesImpl.java:225)
at android.support.v7.preference.Preference.getPersistedString(Preference.java:1601)
at android.support.v7.preference.EditTextPreference.onSetInitialValue(EditTextPreference.java:92)
at android.support.v7.preference.Preference.dispatchSetInitialValue(Preference.java:1517)
at android.support.v7.preference.Preference.onAttachedToHierarchy(Preference.java:1245)
at android.support.v7.preference.Preference.onAttachedToHierarchy(Preference.java:1257)
at android.support.v7.preference.PreferenceGroup.addPreference(PreferenceGroup.java:194)
at android.support.v7.preference.PreferenceGroup.addItemFromInflater(PreferenceGroup.java:126)
at android.support.v7.preference.PreferenceInflater.rInflate(PreferenceInflater.java:355)
at android.support.v7.preference.PreferenceInflater.inflate(PreferenceInflater.java:162)
at android.support.v7.preference.PreferenceInflater.inflate(PreferenceInflater.java:112)
at android.support.v7.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:138)
at android.support.v7.preference.PreferenceFragmentCompat.addPreferencesFromResource(PreferenceFragmentCompat.java:432)
at in.snotes.snotes.settings.PreferenceFragment.onCreatePreferences(PreferenceFragment.java:12)
at android.support.v7.preference.PreferenceFragmentCompat.onCreate(PreferenceFragmentCompat.java:224)
at android.support.v4.app.Fragment.performCreate(Fragment.java:2246)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1377)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1650)
at android.support.v4.app.FragmentManagerImpl.addFragment(FragmentManager.java:1906)
at android.support.v4.app.FragmentManagerImpl.onCreateView(FragmentManager.java:3698)
at android.support.v4.app.FragmentController.onCreateView(FragmentController.java:111)
at android.support.v4.app.FragmentActivity.dispatchFragmentsOnCreateView(FragmentActivity.java:350)
at android.support.v4.app.BaseFragmentActivityApi14.onCreateView(BaseFragmentActivityApi14.java:39)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:67)
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.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
02-21 22:23:36.575 8813-8813/in.snotes.snotes E/AndroidRuntime: at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at in.snotes.snotes.settings.PreferenceActivity.onCreate(PreferenceActivity.java:21)
at android.app.Activity.performCreate(Activity.java:6672)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:757)
I had a switch preference before the edit text preference and that worked fine. Once i replaced the switch preference with edit text preference, this error is thrown.
How do I fix this?
Can you try the code below?
strings.xml
<string name="pin_default_value">0000</string>
preference.xml
<EditTextPreference
android:defaultValue="#string/pin_default_value"
android:key="#string/pin"
android:summary="Set Pin for Notes"
android:title="Password" />
Android is trying to set default value but it is reading 0000 as an Integer and not as a String Main reason is that android:defaultValue is not directly handled as String. This way, to avoid this int to Stringconversion error, you must explicit use a String value (by using some string from strings.xml.
Note
You may need to clear your app data since that wrong default value may be stored in cached files already.

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.

Android: Can't inflate class fragment

I am trying to understand how fragments work, but i haven't had sucess so far.
This is only an example nothing usefull.
when i try to add a fragment to the layout I get always the same error.
I don't know what is missing
Fragment Class
package com.app.danieltavares.teste;
import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class TestFragment extends Fragment{
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.testefrag,container,false);
}
}
ActivityClass
package com.app.danieltavares.teste;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Layout Fragment
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<RadioButton
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="diusdb"/>
</LinearLayout>
Layout that uses the fragments
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.app.danieltavares.teste.MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!" />
<fragment
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.app.danieltavares.teste.TestFragment"
tools:layout="#layout/testefrag"></fragment>
</RelativeLayout>
Logcat
08-23 18:35:21.867 15308-15308/com.app.danieltavares.teste E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.app.danieltavares.teste, PID: 15308
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.app.danieltavares.teste/com.app.danieltavares.teste.MainActivity}: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class fragment
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:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class fragment
Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class fragment
Caused by: java.lang.IllegalArgumentException: Binary XML file line #16: Must specify unique android:id, android:tag, or have a parent with an id for com.app.danieltavares.teste.TestFragment
at android.app.FragmentManagerImpl.onCreateView(FragmentManager.java:2282)
at android.app.FragmentController.onCreateView(FragmentController.java:98)
at android.app.Activity.onCreateView(Activity.java:5884)
at android.support.v4.app.BaseFragmentActivityHoneycomb.onCreateView(BaseFragmentActivityHoneycomb.java:34)
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:80)
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.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:276)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:136)
at com.app.danieltavares.teste.MainActivity.onCreate(MainActivity.java:11)
at android.app.Activity.performCreate(Activity.java:6664)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
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:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.IllegalArgumentException: Binary XML file line #16: Must specify unique android:id, android:tag, or have a parent with an id for com.app.danieltavares.teste.TestFragment
Add an android:id attribute to the <fragment> element in your layout file.

Categories

Resources