airbnb / paris

Define and apply styles to Android views programmatically

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Crash on Samsung 4.4 devices when setting backgroundTint

miguelaboliveira opened this issue · comments

I'm not sure if this is related with another issues reported on Samsung devices, but I'm getting the following crash

  • OS Version: 4.4.2
  • Device: Galaxy Young2, Galaxy Note2
Caused by android.content.res.Resources$NotFoundException: File res/drawable-mdpi/tw_ic_bullet_key_permission_light.png from drawable resource ID #0x1080a23: .xml extension required
       at android.content.res.Resources.loadColorStateList(Resources.java:3619)
       at android.content.res.TypedArray.getColorStateList(TypedArray.java:343)
       at com.airbnb.paris.typed_array_wrappers.TypedArrayTypedArrayWrapper.getColorStateList(TypedArrayTypedArrayWrapper.kt:34)
       at android.view.ViewStyleApplier.processAttributes(ViewStyleApplier.java:101)
       at com.airbnb.paris.StyleApplier.apply(StyleApplier.kt:60)
       at android.view.ViewGroupStyleApplier.applyParent(ViewGroupStyleApplier.java:24)
       at com.airbnb.paris.StyleApplier.apply(StyleApplier.kt:47)
       at com.airbnb.paris.StyleApplier.apply(StyleApplier.kt:40)
       at com.smithmicro.safepath.family.core.activities.main.MainActivity.initViews(MainActivity.java:229)
       at com.smithmicro.safepath.family.core.activities.main.MainActivity.onCreate(MainActivity.java:187)
       at android.app.Activity.performCreate(Activity.java:5484)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2400)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2498)
       at android.app.ActivityThread.access$900(ActivityThread.java:179)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1324)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:146)
       at android.app.ActivityThread.main(ActivityThread.java:5641)
       at java.lang.reflect.Method.invokeNative(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:515)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1288)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1104)
       at dalvik.system.NativeStart.main(NativeStart.java)

I'm doing

Paris.style(mBottomNavigationView).apply(R.style.SafePath_BottomNavigationView_Transparent);

where

<style name="SafePath.BottomNavigationView.Transparent">
    <item name="android:background">@android:color/transparent</item>
</style>

and the crash seems to be happening due to

if (a.hasValue(styleable.Paris_View_android_backgroundTint)) {
    ((ViewProxy)this.getProxy()).setBackgroundTint(a.getColorStateList(styleable.Paris_View_android_backgroundTint));
}

inside ViewStyleApplier.class

Thanks for the report @iamrocklobster ! I think you've narrowed down the issue very well. Right now the background tint is assumed to be a color state list, which is apparently an incorrect assumption. I'll try to take a look when I can, but in the meantime please feel free to propose changes to ViewStyleApplier via pull request.

I'm facing the same problem when setting style with a backgroundColor (color state list)