DEV Community

Nor
Nor

Posted on

Android 7 Button textAllCaps and material design cause ArrayIndexOutOfBoundsException

Android 7 + <Button android:textAllCaps /> + google material design + <item name="android:fontFamily">sans-serif</item> in theme.xml

Caused by: android.view.InflateException: Binary XML file line #68: Error inflating class Button    
Caused by: java.lang.ArrayIndexOutOfBoundsException: length=34; index=1148                          
Enter fullscreen mode Exit fullscreen mode
  • @comments-copied:
              <!-- - @pb[Android 7 Button textAllCaps and material design cause ArrayIndexOutOfBoundsException] -->
              <!--   - FATAL EXCEPTION: main (Ask Gemini)                                                                              -->
              <!--     Process: com.fitmao.bodyscanner, PID: 7227                                                                      -->
              <!--     android.view.InflateException: Binary XML file line #68: Binary XML file line #68: Error inflating class Button -->
              <!--     Caused by: android.view.InflateException: Binary XML file line #68: Error inflating class Button                -->
              <!--     Caused by: java.lang.ArrayIndexOutOfBoundsException: length=34; index=1148                                      -->
              <!--   - {>"                                                                                                                                                                                              -->
              <!--     #### Step 3: The Bug on Android 7 (The Wrong Map Reference)                                                                                                                                      -->
              <!--     - On a normal, working Android version, when the `MaterialButton` asks the OS, "Where is the style information for `textAllCaps`?", the OS gives back a correct index, like "It's in column #5". -->
              <!--     - On Android 7 (API 24/25), there is a bug in the OS's resource system. When the `MaterialButton` asks the same question, the OS gives back a garbage index, like "It's in column #1148".        -->
              <!--   - @compatibility: Android 7 problem is due to this: -->
              <!--                  android:textAllCaps="false" -->
              <!--   - Seems <item name="android:fontFamily">sans-serif</item> is the root cause... -->
Enter fullscreen mode Exit fullscreen mode

Top comments (0)