Raycast throws error on Nexus 7, but not in editor

Hello, I am having a strange problem with my code only when I deploy it to my tablet. In the editor this works perfectly, as the player jumps when it’s ‘grounded’ (on the ground), and no error shows up.

This is how that particular function looks like, and on device, when I see the Logcat, I get a NullReferenceException.

        bool grounded = false;
	bool playerEnableControls = true;

[...]

void Jump()
	{
		if(playerEnableControls)
		{
			grounded = Physics2D.Raycast(groundCheck.transform.position, -Vector2.up, groundRadius, groundMask);
		
			if(grounded  Input.GetKeyDown(KeyCode.Space))
				rigidbody2D.AddForce(new Vector2(0, jumpForce));
		}
	
[...]

The line that throws the error is indicated to be this one:

grounded = Physics2D.Raycast(groundCheck.transform.position, -Vector2.up, groundRadius, groundMask);

I can’t see what’s wrong, especially when in the editor everything works without any error or warning. I thought that testing in the editor (with code that is not specific to the mobile platform) would give me identical results to running it on an actual device. Why would it behave differently when deploying to my Nexus 7?

Any

can cause bizarre issues since script executions can stop on strange places.

Use Debug.log to check out which of those variables are null and then check why the variable is null.