https://kotlinlang.org logo
#anko
Title
n

nickk

12/19/2018, 6:03 PM
Hi! Any idea why the themed version crashes, with
UnsupportedOperationException
?
themedEditText
works fine, for instance.
Copy code
// fine
    textView("> Hello from code $count") {
    }

    // crashes
    themedTextView("> Hello from code $count", theme = R.style.TextLarge2) {
    }
AS 3.2, anko 0.10.8
m

miha-x64

12/20/2018, 11:59 AM
...and a stack trace?
n

nickk

12/20/2018, 12:06 PM
@miha-x64 here you are…. java.lang.UnsupportedOperationException: Failed to resolve attribute at index 4: TypedValue{t=0x2/d=0x1010099 a=1} at android.content.res.TypedArray.getColor(TypedArray.java:469) at android.widget.TextView.<init>(TextView.java:892) at android.widget.TextView.<init>(TextView.java:818) at android.widget.TextView.<init>(TextView.java:814) at android.widget.TextView.<init>(TextView.java:810) at org.jetbrains.anko.$$Anko$Factories$Sdk27View$TEXT_VIEW$1.invoke(Views.kt:58) at org.jetbrains.anko.$$Anko$Factories$Sdk27View$TEXT_VIEW$1.invoke(Views.kt:15) at fieldobservations.ui.SymptomsActivity.createExpandableView(SymptomsActivity.kt:221)
m

miha-x64

12/20/2018, 12:20 PM
Your theme seems to be invalid. Expected colour, given something different.
n

nickk

12/20/2018, 12:34 PM
Well, this is what I thought too, but can you spot something wrong in this style?
Copy code
<style name="TextLarge2" parent="TextAppearance.AppCompat.Medium">
        <item name="android:fontFamily">sans-serif</item>
        <item name="android:textSize">22sp</item>
        <item name="android:layout_margin">8dp</item>
        <item name="android:textColor">#ffffff</item>
        <item name="android:background">@color/colorPrimary</item>
    </style>
(when used from xml, nothing seems to explode)
@miha-x64 The error is also triggered by this style:
Copy code
<style name="TextLarge3" parent="TextAppearance.AppCompat.Medium">

    </style>
😰 1
m

miha-x64

12/20/2018, 12:57 PM
looks like
com.android.internal.R.styleable.TextAppearance_textColorHighlight
is the cause
n

nickk

12/20/2018, 12:58 PM
And not only this one. Overriding it, you get a crash at at index 5 instead of 4…
The joy of using C-style APIs in Java…
😡 1
20 Views