Есть ошибка, надувающая TextView в Android 10.0 - PullRequest
0 голосов
/ 24 февраля 2020

В Android 10.0 Я получаю эту ошибку, когда пытаюсь надуть макет frag_home_banner. xml фрагмента в viewPager. Показывает «Ошибка надувания класса TextView».

Интересно, что в младших android версиях ошибки нет, все работает нормально.

Что может быть причиной этого?

Сообщение об ошибке

Caused by: android.view.InflateException: Binary XML file line #34 in kz.mk:layout/fragment_home_banner: Binary XML file line #34 in kz.mk:layout/fragment_home_banner: Error inflating class TextView
W/System.err: Caused by: android.view.InflateException: Binary XML file line #34 in kz.mk:layout/fragment_home_banner: Error inflating class TextView
Caused by: java.lang.IndexOutOfBoundsException: index=0 out of bounds (limit=0, nb=4)
at java.nio.Buffer.checkIndex(Buffer.java:564)
at java.nio.DirectByteBuffer.getInt(DirectByteBuffer.java:570)
at android.graphics.fonts.FontFileUtil.analyzeStyle(FontFileUtil.java:94)
at android.graphics.fonts.Font$Builder.build(Font.java:364)
W/System.err:     at android.graphics.Typeface$Builder.build(Typeface.java:596)
at android.content.res.ResourcesImpl.loadFont(ResourcesImpl.java:980)
at android.content.res.Resources.getFont(Resources.java:400)
at android.content.res.TypedArray.getFont(TypedArray.java:1035)
at android.widget.TextView.readTextAppearance(TextView.java:3991)
W/System.err:     at android.widget.TextView.<init>(TextView.java:1064)
at android.widget.TextView.<init>(TextView.java:968)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:87)
at android.support.v7.widget.AppCompatTextView.<init>(AppCompatTextView.java:83)
W/System.err:     at android.support.v7.app.AppCompatViewInflater.createTextView(AppCompatViewInflater.java:177)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:102)
at android.support.v7.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
at android.support.v7.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
W/System.err:     at android.view.LayoutInflater$FactoryMerger.onCreateView(LayoutInflater.java:242)
at android.view.LayoutInflater.tryCreateView(LayoutInflater.java:1061)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:997)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:961)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1123)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1126)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1084)
at android.view.LayoutInflater.inflate(LayoutInflater.java:682)
at android.view.LayoutInflater.inflate(LayoutInflater.java:534)
at kz.presentation.fragment.homebannerpage.BannerPageFragment.onCreateView(BannerPageFragment.kt:19)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2439)
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:2625)
W/System.err:     at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2243)
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.setAdapter(ViewPager.java:540)
at kz.presentation.fragment.home.HomeFragment.initViewPager(HomeFragment.kt:156)
at kz.presentation.fragment.home.HomeView$$State.initViewPager(HomeView$$State.java:281)
at kz.presentation.fragment.home.HomePresenter.onGetBannersSuccess(HomePresenter.kt:121)
at kz.presentation.fragment.home.HomePresenter.access$onGetBannersSuccess(HomePresenter.kt:19)
at kz.presentation.fragment.home.HomePresenter$getBanners$1.invoke(HomePresenter.kt:116)
W/System.err:     at kz.presentation.fragment.home.HomePresenter$getBanners$1.invoke(HomePresenter.kt:19)
at kz.presentation.fragment.home.HomePresenter$sam$io_reactivex_functions_Consumer$0.accept(Unknown Source:2)
at io.reactivex.internal.observers.ConsumerSingleObserver.onSuccess(ConsumerSingleObserver.java:62)
at io.reactivex.internal.operators.single.SingleMap$MapSingleObserver.onSuccess(SingleMap.java:64)
at io.reactivex.internal.operators.single.SingleObserveOn$ObserveOnSingleObserver.run(SingleObserveOn.java:81)
at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:124)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

frag_home_banner. xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:cardCornerRadius="@dimen/corner_radius"
    >

    <ImageView
        android:id="@+id/fr_homebanner_banner"
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:adjustViewBounds="true"
        android:scaleType="centerCrop"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        />


    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toTopOf="@+id/fr_homebanner_banner"
        app:layout_constraintStart_toStartOf="@+id/fr_homebanner_banner"
        android:layout_marginStart="16dp"
        app:layout_constraintBottom_toBottomOf="@+id/fr_homebanner_banner"
        android:orientation="vertical"
        >

       <TextView
            android:id="@+id/fr_home_banner_text_1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="@font/franklin_gothic_book_2"
            android:textColor="#000000"
            android:textSize="12sp"
            tools:text="К весенним праздникам"/>

         <TextView
            android:id="@+id/fr_home_banner_text_2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:fontFamily="@font/stroke_medium"
            android:textColor="#000000"
            android:textSize="20sp"
            tools:text="БЕСПЛАТНО"/>

        <TextView
            android:id="@+id/fr_home_banner_text_3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="-6dp"
            android:fontFamily="@font/franklin_gothic_demi_cond"
            android:textColor="#000000"
            android:textSize="20sp"
            android:textStyle="bold"
            tools:text="УльтраЧистка" tools:visibility="visible"/>

        <TextView
            android:id="@+id/fr_home_banner_text_4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="-3dp"
            android:fontFamily="@font/franklin_gothic_book_2"
            android:textColor="#000000"
            android:textSize="12sp" tools:text="украшений"/>
    </LinearLayout>

</android.support.constraint.ConstraintLayout>

1 Ответ

0 голосов
/ 24 февраля 2020

TTF-файлы были пусты. В более старых версиях android эта ошибка игнорировалась. Вот почему он работал нормально на предыдущих версиях и сбой на Android 10.0

...