[TextView] Crash when using custom style
See original GitHub issueDescription:
I am facing a crash at TextView
after update my Material Android Library to version 1.2.0
from 1.1.0
.
Error Code:
Error inflating class TextView
Caused by: java.lang.IllegalArgumentException: Font {path=null, style=FontStyle { weight=400, slant=0}, ttcIndex=0, axes=, localeList=, buffer=java.nio.DirectByteBuffer[pos=0 lim=433584 cap=433584]} has already been added
Source code:
This is my TextView
element.
<TextView
android:id="@+id/dashboardMessageTV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFF3EF"
android:drawableStart="@drawable/ic_info"
android:drawablePadding="4dp"
android:gravity="start|center_vertical"
android:paddingStart="4dp"
android:paddingTop="8dp"
android:paddingEnd="4dp"
android:paddingBottom="8dp"
android:textAlignment="gravity"
android:textAppearance="@style/CustomTextParagraph"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
And this is my CustomTextParagraph
style.
<style name="CustomTextParagraph" parent="@android:style/TextAppearance.Small">
<item name="android:textStyle">normal</item>
<item name="android:fontFamily">@font/sf_pro</item>
<item name="android:textColor">@color/darkGray</item>
</style>
This is my theme parent.
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
Android API version: Android 10 (API level 29)
Material Library version:
implementation 'com.google.android.material:material:1.2.0'
Device: Xiao Mi 9
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Why the app crashes, when I trying to set a text size attribute ...
When I trying to apply a custom style to my TextView , and trying to specify the textSize attribute not via value in...
Read more >Problems with themes and attributes when build running app ...
Description: The main issue I would like to report is that the app crashes when it tires to use a custom attribute in...
Read more >Spans | Android Developers
Spans are powerful markup objects that you can use to style text at a ... You can also create your own spans to...
Read more >Xcode 11 crashes while using attri… | Apple Developer Forums
Xcode is crashing every time I try to click on the text field of a text view or button after switching Title to...
Read more >Underspanding spans - Medium
2. Text style changes by adding/removing spans · textView.setText(CharSequence) two times: first to set the initial text and then again when the button...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Check your
@font/sf_pro
.This kind of error in shown when you try to register multiple fonts with the same style and weight into the same font family (and it is related to
androidx.core
version1.2.0
and higher).The issue should be here because both font elements have the same values for the
fontStyle
andfontWeight
: