BCE0019: 'mesh' is not a member of 'UnityEngine.Component' on Android Build

When trying to Build a game for android, I get this error "BCE0019: 'mesh' is not a member of 'UnityEngine.Component'" 3 times.

In here

if(GetComponent(MeshFilter).mesh == null)
    GetComponent(MeshFilter).mesh = new Mesh();

& in here

var mesh : Mesh = GetComponent(MeshFilter).mesh;

Anybody any idea on how to fix this?

Thanks in advance!!

GetComponent returns Component, and indeed mesh is not a member of Component. If you're not using dynamic typing then you have to cast it correctly. If you want less typing, use generics.

GetComponent.<MeshFilter>().mesh = ...

Again. I'm gonna awnser my own question... I've got to stop asking to quickly :D

here's the working code:

    if((GetComponent(MeshFilter) as MeshFilter).mesh == null)
    (GetComponent(MeshFilter) as MeshFilter).mesh = new Mesh(); 

&

    var mesh : Mesh = (GetComponent(MeshFilter) as MeshFilter).mesh

I still don't know how this works, so if someone could clarify on this, would be great..