0

Running app on Android version 7.1.1 device. Was working perfectly then suddenly I got this inflation exception error.

XML file:

<com.google.android.material.textview.MaterialTextView
    android:id="@+id/titleLogin"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:fontFamily="sans-serif"
    android:paddingStart="20dp"
    android:paddingTop="20dp"
    android:paddingBottom="10dp"
    android:text="Login"
    android:textColor="@color/black"
    android:textSize="34sp"
    android:textStyle="bold"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.5"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0"
    app:layout_constraintWidth_percent=".8" />

Logcat:

Caused by: android.view.InflateException: Binary XML file line #53: Binary XML file line #53: Error inflating class com.google.android.material.textview.MaterialTextView
     Caused by: android.view.InflateException: Binary XML file line #53: Error inflating class com.google.android.material.textview.MaterialTextView
     Caused by: java.lang.reflect.InvocationTargetException

I tried changing MaterialTextView to TextView, did not work.

As I don't have any drawable or layouts imported I don't know why the problem is there. As I said, was working fine one moment and crashed the next.

Does the same with a button as well...

Stack trace:

2022-10-29 21:16:00.512 12386-12386/com.poweredbyralph.southernlines E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.poweredbyralph.southernlines, PID: 12386
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.poweredbyralph.southernlines/com.poweredbyralph.southernlines.LoginActivity}: android.view.InflateException: Binary XML file line #53: Binary XML file line #53: Error inflating class com.google.android.material.textview.MaterialTextView
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2798)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2863)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:110)
        at android.os.Looper.loop(Looper.java:203)
        at android.app.ActivityThread.main(ActivityThread.java:6410)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
     Caused by: android.view.InflateException: Binary XML file line #53: Binary XML file line #53: Error inflating class com.google.android.material.textview.MaterialTextView
     Caused by: android.view.InflateException: Binary XML file line #53: Error inflating class com.google.android.material.textview.MaterialTextView
     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 android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787)
        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 android.view.LayoutInflater.inflate(LayoutInflater.java:426)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:377)
        at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:710)
        at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:195)
        at com.poweredbyralph.southernlines.LoginActivity.onCreate(LoginActivity.java:39)
        at android.app.Activity.performCreate(Activity.java:6681)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2751)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2863)
        at android.app.ActivityThread.-wrap12(ActivityThread.java)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
        at android.os.Handler.dispatchMessage(Handler.java:110)
        at android.os.Looper.loop(Looper.java:203)
        at android.app.ActivityThread.main(ActivityThread.java:6410)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1084)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:945)
     Caused by: java.lang.ArrayIndexOutOfBoundsException: length=56; index=930
        at android.content.res.StringBlock.get(StringBlock.java:65)
        at android.content.res.XmlBlock$Parser.getPooledString(XmlBlock.java:458)
        at android.content.res.TypedArray.loadStringValueAt(TypedArray.java:1218)
        at android.content.res.TypedArray.getText(TypedArray.java:168)
        at android.widget.TextView.<init>(TextView.java:1028)
2022-10-29 21:16:00.512 12386-12386/com.poweredbyralph.southernlines E/AndroidRuntime:     at android.widget.TextView.<init>(TextView.java:731)
        at androidx.appcompat.widget.AppCompatTextView.<init>(AppCompatTextView.java:108)
        at com.google.android.material.textview.MaterialTextView.<init>(MaterialTextView.java:88)
        at com.google.android.material.textview.MaterialTextView.<init>(MaterialTextView.java:83)
            ... 31 more
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491

1 Answers1

0

@CommonsWare, this "The error seems to be complaining about a string resource" actually gave me an idea. I changed my TextViews and Buttons to use strings from the strings file rather than adding them directly.

android:text="Login" TO: android:text="@string/login"

Problem solved!! Thanks for pointing String resource out:)