Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19801] Android: CardView causes crash when cardCornerRadius AND backgroundColor are set

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionCannot Reproduce
Resolution Date2015-12-01T02:03:11.000+0000
Affected Version/sRelease 5.1.0
Fix Version/sn/a
ComponentsAndroid
Labelsn/a
ReporterFokke Zandbergen
AssigneeAshraf Abu
Created2015-10-27T11:54:43.000+0000
Updated2017-03-21T22:12:30.000+0000

Description

The following sample demonstrates that the app crashes when you use both the backgroundColor and cardCornerRadius property on a CardView. If you use cardBackgroundColor instead it works.
var win = Ti.UI.createWindow();

var card = Ti.UI.Android.createCardView({
	top: 20,
	left: 20,
	right: 20,
	contentPadding: 20,

	// Remove and it won't crash
	cardCornerRadius: 20,

	// Rename to cardBackgroundColor and it won't crash
	backgroundColor: '#F00'
});

card.add(Ti.UI.createLabel({
	text: 'Hello, world!',
	color: '#000'
}));

win.add(card);

win.open();
*Logs*
[ERROR] TiApplication: (main) [478,478] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{test.android/org.appcelerator.titanium.TiActivity}: java.lang.ClassCastException: android.graphics.drawable.ColorDrawable cannot be cast to android.support.v7.widget.RoundRectDrawable; Titanium 5.1.0,2015/10/26 16:46,c914b0f
[ERROR] TiApplication: java.lang.RuntimeException: Unable to start activity ComponentInfo{test.android/org.appcelerator.titanium.TiActivity}: java.lang.ClassCastException: android.graphics.drawable.ColorDrawable cannot be cast to android.support.v7.widget.RoundRectDrawable
[ERROR] TiApplication: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
[ERROR] TiApplication: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
[ERROR] TiApplication: 	at android.app.ActivityThread.access$800(ActivityThread.java:151)
[ERROR] TiApplication: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
[ERROR] TiApplication: 	at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] TiApplication: 	at android.os.Looper.loop(Looper.java:135)
[ERROR] TiApplication: 	at android.app.ActivityThread.main(ActivityThread.java:5254)
[ERROR] TiApplication: 	at java.lang.reflect.Method.invoke(Native Method)
[ERROR] TiApplication: 	at java.lang.reflect.Method.invoke(Method.java:372)
[ERROR] TiApplication: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
[ERROR] TiApplication: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
[ERROR] TiApplication: Caused by: java.lang.ClassCastException: android.graphics.drawable.ColorDrawable cannot be cast to android.support.v7.widget.RoundRectDrawable
[ERROR] TiApplication: 	at android.support.v7.widget.CardViewApi21.setRadius(CardViewApi21.java:36)
[ERROR] TiApplication: 	at android.support.v7.widget.CardView.setRadius(CardView.java:281)
[ERROR] TiApplication: 	at ti.modules.titanium.ui.widget.TiUICardView.processProperties(TiUICardView.java:62)
[ERROR] TiApplication: 	at org.appcelerator.kroll.KrollProxy.setModelListener(KrollProxy.java:1209)
[ERROR] TiApplication: 	at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:505)
[ERROR] TiApplication: 	at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:496)
[ERROR] TiApplication: 	at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:474)
[ERROR] TiApplication: 	at org.appcelerator.titanium.proxy.TiViewProxy.realizeViews(TiViewProxy.java:512)
[ERROR] TiApplication: 	at org.appcelerator.titanium.proxy.TiViewProxy.handleGetView(TiViewProxy.java:496)
[ERROR] TiApplication: 	at org.appcelerator.titanium.proxy.TiViewProxy.getOrCreateView(TiViewProxy.java:474)
[ERROR] TiApplication: 	at org.appcelerator.titanium.proxy.TiViewProxy.handleAdd(TiViewProxy.java:675)
[ERROR] TiApplication: 	at org.appcelerator.titanium.proxy.TiViewProxy.add(TiViewProxy.jav
[ERROR] TiApplication: 	at ti.modules.titanium.ui.WindowProxy.windowCreated(WindowProxy.java:237)
[ERROR] TiApplication: 	at org.appcelerator.titanium.TiActivityWindows.windowCreated(TiActivityWindows.java:33)
[ERROR] TiApplication: 	at org.appcelerator.titanium.TiBaseActivity.windowCreated(TiBaseActivity.java:501)
[ERROR] TiApplication: 	at org.appcelerator.titanium.TiBaseActivity.onCreate(TiBaseActivity.java:594)
[ERROR] TiApplication: 	at org.appcelerator.titanium.TiActivity.onCreate(TiActivity.java:18)
[ERROR] TiApplication: 	at android.app.Activity.performCreate(Activity.java:5990)
[ERROR] TiApplication: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
[ERROR] TiApplication: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
[ERROR] TiApplication: 	... 10 more
-- End application log -------------------------------------------------------

Comments

  1. Fokke Zandbergen 2015-10-27

    [~msamah] It also crashes if you set both backgroundColor and cardBackgroundColor.
  2. Ashraf Abu 2015-11-18

  3. Fokke Zandbergen 2015-11-18

    Confirmed fixed!
  4. Ashraf Abu 2015-11-19

    Will close this ticket once TIMOB-19796 is merged and resolved.
  5. Lee Morris 2017-03-21

    Closing ticket as the issue cannot be reproduced and due to the above comments.

JSON Source