Как исправить сбои только на устройствах Huawei в android.widget.SearchView - PullRequest
0 голосов
/ 20 ноября 2018
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)

Согласно журналу, это происходит при появлении активности при попытке раздуть поисковое представление.Я использую 'android.widget.SearchView' вместо appcompat, потому что я его анимирую и не могу правильно анимировать версию appcompat.

Я не чувствую, что это живая проблема.Я не могу понять, почему это происходит только на устройствах Huawei.Я выпустил это обновление на прошлой неделе, и оно уже на 100k плюс устройств.По данным Crashlytics, это 100% Huawei и 81% Android 8, 15% Android 7 и 4% Android 6.

Я пробовал try / catch на начальной активности, при создании и в нескольких других местах, но ничего не ловит,Я могу опубликовать код, если необходимо, но хотел посмотреть, было ли это необходимо.

Вот вид поиска в макете

 <SearchView
        android:id="@+id/search_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:alpha="0"
        android:iconifiedByDefault="false"/>

И это инициализирует вид поиска в oncreate

 SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
    if (searchManager != null) {
        searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
    }

Установка setSearchableInfo вызывает updateSearchAutoComplete (), где начинается сбой.Но я попробовал попробовать / поймать там все еще сбои.

...