Экземпляр класса нельзя создать в xml

Я не знаю, почему, но мой класс не может быть создан в XML. Ниже приведен мой код. Я все перепробовал, но ничего не получилось. Пытался аннулировать кэш и перезапуск, ничего не работает.

Customfontextview.Ява

public class CustomFontTextView extends  TextView {

    public static final String ANDROID_SCHEMA = "http://schemas.android.com/apk/res/android";



    public CustomFontTextView(Context context) {
        super(context);

        applyCustomFont(context, null);
    }

    public CustomFontTextView(Context context, AttributeSet attrs) {
        super(context, attrs);

        applyCustomFont(context, attrs);
    }

    public CustomFontTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        applyCustomFont(context, attrs);
    }

    private void applyCustomFont(Context context, AttributeSet attrs) {
        TypedArray attributeArray = context.obtainStyledAttributes(
                attrs,
                R.styleable.CustomFontTextView);

        String fontName = attributeArray.getString(R.styleable.CustomFontTextView_font);
        int textStyle = attrs.getAttributeIntValue(ANDROID_SCHEMA, "textStyle", Typeface.NORMAL);

        Typeface customFont = selectTypeface(context, fontName, textStyle);
        setTypeface(customFont);

        attributeArray.recycle();
    }

    private Typeface selectTypeface(Context context, String fontName, int textStyle) {
        if (fontName.contentEquals(context.getString(R.string.font_name_fontawesome))) {
            return FontCache.getTypeface("fontawesome.ttf", context);
        } else if (fontName.contentEquals(context.getString(R.string.font_name_source_sans_pro))) {
          /*
          information about the TextView textStyle:
          http://developer.android.com/reference/android/R.styleable.html#TextView_textStyle
          */
            switch (textStyle) {
                case Typeface.BOLD: // bold
                    return FontCache.getTypeface("SourceSansPro-Bold.ttf", context);

                case Typeface.ITALIC: // italic
                    return FontCache.getTypeface("SourceSansPro-Italic.ttf", context);

                case Typeface.BOLD_ITALIC: // bold italic
                    return FontCache.getTypeface("SourceSansPro-BoldItalic.ttf", context);

                case Typeface.NORMAL: // regular
                default:
                    return FontCache.getTypeface("SourceSansPro-Regular.ttf", context);
            }
        } else {
            // no matching font found
            // return null so Android just uses the standard font (Roboto)
            return null;
        }
    }
}

деятельность.главный

<LinearLayout 
    
    android_layout_width="match_parent"
    android_layout_height="match_parent"
    android_orientation="vertical">

    <TextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="Reenath"
        android_textSize="18sp"/>

    <com.trupik.virtualmall.activity.customfonts.CustomFontTextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="Reenath"
        android_textSize="18sp"
        app_font="@string/font_name_source_sans_pro"/>

    <com.trupik.virtualmall.activity.customfonts.CustomFontTextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="Reenath"
        android_textSize="18sp"
        android_textStyle="bold"
        app_font="@string/font_name_source_sans_pro"/>

    <com.trupik.virtualmall.activity.customfonts.CustomFontTextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="Reenath"
        android_textSize="18sp"
        android_textStyle="italic"
        app_font="@string/font_name_fontawesome"/>

    <com.trupik.virtualmall.activity.customfonts.CustomFontTextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="&#xf135;&#xf135;&#xf135;&#xf135;&#xf135;"
        android_textSize="18sp"
        app_font="@string/font_name_fontawesome"/>
    </LinearLayout>

Исключение

java.lang.NumberFormatException: For input string: "italic"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Long.parseLong(Long.java:441)
    at com.android.internal.util.XmlUtils_Delegate.convertValueToInt(XmlUtils_Delegate.java:72)
    at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:93)
    at android.util.BridgeXmlPullAttributes.getAttributeIntValue(BridgeXmlPullAttributes.java:134)
    at com.android.layoutlib.bridge.android.BridgeXmlBlockParser.getAttributeIntValue(BridgeXmlBlockParser.java:436)
    at com.trupik.virtualmall.activity.customfonts.CustomFontTextView.applyCustomFont(CustomFontTextView.java:41)
    at com.trupik.virtualmall.activity.customfonts.CustomFontTextView.<init>(CustomFontTextView.java:26)
    at sun.reflect.GeneratedConstructorAccessor481.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:458)
    at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:158)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:103)
    at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:168)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:247)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:171)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:835)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:223)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
    at com.android.tools.idea.rendering.RenderTask.compute(RenderTask.java:510)
    at com.android.tools.idea.rendering.RenderTask.compute(RenderTask.java:498)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:498)
    at com.android.tools.idea.rendering.RenderTask.access0(RenderTask.java:72)
    at com.android.tools.idea.rendering.RenderTask.call(RenderTask.java:610)
    at com.android.tools.idea.rendering.RenderTask.call(RenderTask.java:607)
    at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:362)
    at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:607)
    at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:629)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:652)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access00(AndroidLayoutPreviewToolWindowManager.java:80)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager

I don't know why but my class cannot be instantiated in XML. Below is my Code. I tried everything, but nothing seems to be working. Tried invalidating cache and restarting , nothing works.

CustomFontTextView.java

public class CustomFontTextView extends  TextView {

    public static final String ANDROID_SCHEMA = "http://schemas.android.com/apk/res/android";



    public CustomFontTextView(Context context) {
        super(context);

        applyCustomFont(context, null);
    }

    public CustomFontTextView(Context context, AttributeSet attrs) {
        super(context, attrs);

        applyCustomFont(context, attrs);
    }

    public CustomFontTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        applyCustomFont(context, attrs);
    }

    private void applyCustomFont(Context context, AttributeSet attrs) {
        TypedArray attributeArray = context.obtainStyledAttributes(
                attrs,
                R.styleable.CustomFontTextView);

        String fontName = attributeArray.getString(R.styleable.CustomFontTextView_font);
        int textStyle = attrs.getAttributeIntValue(ANDROID_SCHEMA, "textStyle", Typeface.NORMAL);

        Typeface customFont = selectTypeface(context, fontName, textStyle);
        setTypeface(customFont);

        attributeArray.recycle();
    }

    private Typeface selectTypeface(Context context, String fontName, int textStyle) {
        if (fontName.contentEquals(context.getString(R.string.font_name_fontawesome))) {
            return FontCache.getTypeface("fontawesome.ttf", context);
        } else if (fontName.contentEquals(context.getString(R.string.font_name_source_sans_pro))) {
          /*
          information about the TextView textStyle:
          http://developer.android.com/reference/android/R.styleable.html#TextView_textStyle
          */
            switch (textStyle) {
                case Typeface.BOLD: // bold
                    return FontCache.getTypeface("SourceSansPro-Bold.ttf", context);

                case Typeface.ITALIC: // italic
                    return FontCache.getTypeface("SourceSansPro-Italic.ttf", context);

                case Typeface.BOLD_ITALIC: // bold italic
                    return FontCache.getTypeface("SourceSansPro-BoldItalic.ttf", context);

                case Typeface.NORMAL: // regular
                default:
                    return FontCache.getTypeface("SourceSansPro-Regular.ttf", context);
            }
        } else {
            // no matching font found
            // return null so Android just uses the standard font (Roboto)
            return null;
        }
    }
}

activity.main

<LinearLayout 
    
    android_layout_width="match_parent"
    android_layout_height="match_parent"
    android_orientation="vertical">

    <TextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="Reenath"
        android_textSize="18sp"/>

    <com.trupik.virtualmall.activity.customfonts.CustomFontTextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="Reenath"
        android_textSize="18sp"
        app_font="@string/font_name_source_sans_pro"/>

    <com.trupik.virtualmall.activity.customfonts.CustomFontTextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="Reenath"
        android_textSize="18sp"
        android_textStyle="bold"
        app_font="@string/font_name_source_sans_pro"/>

    <com.trupik.virtualmall.activity.customfonts.CustomFontTextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="Reenath"
        android_textSize="18sp"
        android_textStyle="italic"
        app_font="@string/font_name_fontawesome"/>

    <com.trupik.virtualmall.activity.customfonts.CustomFontTextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="&#xf135;&#xf135;&#xf135;&#xf135;&#xf135;"
        android_textSize="18sp"
        app_font="@string/font_name_fontawesome"/>
    </LinearLayout>

Exception

java.lang.NumberFormatException: For input string: "italic"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Long.parseLong(Long.java:441)
    at com.android.internal.util.XmlUtils_Delegate.convertValueToInt(XmlUtils_Delegate.java:72)
    at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:93)
    at android.util.BridgeXmlPullAttributes.getAttributeIntValue(BridgeXmlPullAttributes.java:134)
    at com.android.layoutlib.bridge.android.BridgeXmlBlockParser.getAttributeIntValue(BridgeXmlBlockParser.java:436)
    at com.trupik.virtualmall.activity.customfonts.CustomFontTextView.applyCustomFont(CustomFontTextView.java:41)
    at com.trupik.virtualmall.activity.customfonts.CustomFontTextView.<init>(CustomFontTextView.java:26)
    at sun.reflect.GeneratedConstructorAccessor481.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:458)
    at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:158)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:103)
    at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:168)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:247)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:171)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:835)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:223)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:510)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:498)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:498)
    at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72)
    at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:610)
    at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:607)
    at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:362)
    at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:607)
    at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:629)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:652)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:80)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:594)
    at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:589)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

.run(AndroidLayoutPreviewToolWindowManager.java:594)
at com.intellij.openapi.progress.impl.CoreProgressManager.run(CoreProgressManager.java:152)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137)
at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.run(AndroidLayoutPreviewToolWindowManager.java:589)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:254)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
at com.intellij.util.Alarm$Request

I don't know why but my class cannot be instantiated in XML. Below is my Code. I tried everything, but nothing seems to be working. Tried invalidating cache and restarting , nothing works.

CustomFontTextView.java

public class CustomFontTextView extends  TextView {

    public static final String ANDROID_SCHEMA = "http://schemas.android.com/apk/res/android";



    public CustomFontTextView(Context context) {
        super(context);

        applyCustomFont(context, null);
    }

    public CustomFontTextView(Context context, AttributeSet attrs) {
        super(context, attrs);

        applyCustomFont(context, attrs);
    }

    public CustomFontTextView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);

        applyCustomFont(context, attrs);
    }

    private void applyCustomFont(Context context, AttributeSet attrs) {
        TypedArray attributeArray = context.obtainStyledAttributes(
                attrs,
                R.styleable.CustomFontTextView);

        String fontName = attributeArray.getString(R.styleable.CustomFontTextView_font);
        int textStyle = attrs.getAttributeIntValue(ANDROID_SCHEMA, "textStyle", Typeface.NORMAL);

        Typeface customFont = selectTypeface(context, fontName, textStyle);
        setTypeface(customFont);

        attributeArray.recycle();
    }

    private Typeface selectTypeface(Context context, String fontName, int textStyle) {
        if (fontName.contentEquals(context.getString(R.string.font_name_fontawesome))) {
            return FontCache.getTypeface("fontawesome.ttf", context);
        } else if (fontName.contentEquals(context.getString(R.string.font_name_source_sans_pro))) {
          /*
          information about the TextView textStyle:
          http://developer.android.com/reference/android/R.styleable.html#TextView_textStyle
          */
            switch (textStyle) {
                case Typeface.BOLD: // bold
                    return FontCache.getTypeface("SourceSansPro-Bold.ttf", context);

                case Typeface.ITALIC: // italic
                    return FontCache.getTypeface("SourceSansPro-Italic.ttf", context);

                case Typeface.BOLD_ITALIC: // bold italic
                    return FontCache.getTypeface("SourceSansPro-BoldItalic.ttf", context);

                case Typeface.NORMAL: // regular
                default:
                    return FontCache.getTypeface("SourceSansPro-Regular.ttf", context);
            }
        } else {
            // no matching font found
            // return null so Android just uses the standard font (Roboto)
            return null;
        }
    }
}

activity.main

<LinearLayout 
    
    android_layout_width="match_parent"
    android_layout_height="match_parent"
    android_orientation="vertical">

    <TextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="Reenath"
        android_textSize="18sp"/>

    <com.trupik.virtualmall.activity.customfonts.CustomFontTextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="Reenath"
        android_textSize="18sp"
        app_font="@string/font_name_source_sans_pro"/>

    <com.trupik.virtualmall.activity.customfonts.CustomFontTextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="Reenath"
        android_textSize="18sp"
        android_textStyle="bold"
        app_font="@string/font_name_source_sans_pro"/>

    <com.trupik.virtualmall.activity.customfonts.CustomFontTextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="Reenath"
        android_textSize="18sp"
        android_textStyle="italic"
        app_font="@string/font_name_fontawesome"/>

    <com.trupik.virtualmall.activity.customfonts.CustomFontTextView
        android_layout_width="wrap_content"
        android_layout_height="wrap_content"
        android_layout_margin="12dp"
        android_text="&#xf135;&#xf135;&#xf135;&#xf135;&#xf135;"
        android_textSize="18sp"
        app_font="@string/font_name_fontawesome"/>
    </LinearLayout>

Exception

java.lang.NumberFormatException: For input string: "italic"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Long.parseLong(Long.java:441)
    at com.android.internal.util.XmlUtils_Delegate.convertValueToInt(XmlUtils_Delegate.java:72)
    at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:93)
    at android.util.BridgeXmlPullAttributes.getAttributeIntValue(BridgeXmlPullAttributes.java:134)
    at com.android.layoutlib.bridge.android.BridgeXmlBlockParser.getAttributeIntValue(BridgeXmlBlockParser.java:436)
    at com.trupik.virtualmall.activity.customfonts.CustomFontTextView.applyCustomFont(CustomFontTextView.java:41)
    at com.trupik.virtualmall.activity.customfonts.CustomFontTextView.<init>(CustomFontTextView.java:26)
    at sun.reflect.GeneratedConstructorAccessor481.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
    at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:458)
    at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:158)
    at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:103)
    at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:168)
    at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:247)
    at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:171)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:835)
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
    at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:223)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:510)
    at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:498)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:888)
    at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:498)
    at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72)
    at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:610)
    at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:607)
    at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:362)
    at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:607)
    at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:629)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:652)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:80)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:594)
    at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:152)
    at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:452)
    at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:402)
    at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
    at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:137)
    at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:589)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
    at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
    at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
    at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
    at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

.run(Alarm.java:351)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

2 ответа

  1. его трудно сказать, что это проблема без вашегоlogcat

    В любом случае, если вы просто хотите реализовать пользовательские шрифты, я бы предложил каллиграфию

    его довольно просто и прямо вперед.

    Надеюсь, это поможет

  2. Проблема возникает из следующей строки в xml:

    android:textStyle="italic"
    

    Так что, скорее всего, проблема в selectTypefaceметоде. Проверьте, правильно ли вы там справилисьitalic.

    Проблема должна быть решена, но если проблема по-прежнему выйти, я не могу сказать точную причину, как теоретически это не должно создавать проблему, но как это вызывает сбой приложения, и вам нужно исправить его на срочной основе, может быть обходной путь для этого.

    В attrsфайле добавьте следующий атрибут в CustomFontTextViewstyleable:

    <attr name="textStyle">
        <flag name="normal" value="0" />
        <flag name="bold" value="1" />
        <flag name="italic" value="2" />
     </attr>
    

    И в своем CustomFontTextView.javaклассе измените следующую строку:

    int textStyle = attrs.getAttributeIntValue(ANDROID_SCHEMA, "textStyle", Typeface.NORMAL);
    

    к

    int textStyle = attributeArray.getInt(R.styleable.CustomFontTextView_textStyle, Typeface.NORMAL);
    

    И в ваших XML-файлах макета измените все android:textStyleна app:textStyle. Надеюсь, что решение работает для вас.