Box Collider in Trackable Event Handler

Hi, i’m currently making an augmented reality application and want to resize a box collider, but the application just dies when trying to do this.

foreach (Renderer component in rendererComponents) {
        component.enabled = true;
			component.transform.gameObject.AddComponent<BoxCollider>();
			BoxCollider bc = component.transform.GetComponent<BoxCollider>();
			bc.size = new Vector3(0.2f, 0.4f, 0.2f);
			component.transform.gameObject.AddComponent<RotateObject>();
    }

I tried to just get one of the components of the box collider size just to see if i could at least get its value:

float bX = bc.bounds.size.x;

But even with just this like the application dies.

Thanks in advance.

The application just closes. It’s for Android.
I’m adding the box collider immediatly before trying to resize it:

component.transform.gameObject.AddComponent<BoxCollider>();
BoxCollider bc = component.transform.GetComponent<BoxCollider>();
bc.size = new Vector3(0.2f, 0.4f, 0.2f);

It works well if i comment the lines where i try to resize the box collider, but if i uncomment them the application crashes and closes when i try to run it.