'Split' is not a member of 'Object'. Android

Why does it only throw this error when building on android platform?

var urll = “http://xxxxxxxxxxxxxxxxxxxxxxxxxxx”;
var myText : String;
var imageurl : String;

var i = 0;
var ii = 0;
var iii = 0;

function Start() { 

  var guiwww : WWW = new WWW(urll);
  yield guiwww;
  myText = guiwww.text;

  
  var shops = new Array(); 
  shops = myText.Split('*'[0]);

 		 
	  for (i = 0; i < shops.length; i++) {

 
 var graphics = new Array(); 
 graphics = shops*.Split(','[0]);* 

for (iii = 0; iii < graphics.length; iii++) {

imageurl = graphics[iii];

Debug.Log(imageurl);

// Create a texture in DXT1 format

var www : WWW = new WWW (imageurl);

// Wait for download to complete

yield www;

renderer.material.mainTexture = www.texture;

  •    for (ii = 0; ii < graphics.length; ii++) {*
    

// assign texture
var theobjects = “booth”+i;

GameObject.Find(theobjects+“/booth/graphic”+iii).renderer.material.mainTexture = renderer.material.mainTexture;

}
ii = 0;
}

}
i = 0;
ii = 0;
}

You should never use Array; everything in it is Object so you would have to cast when accessing it. Just do

var graphics = shops*.Split(','[0]);*

which makes “graphics” into a String[] array. You should also do “(for var i = 0...” instead of declaring the loop index variables outside the function. Variables should always be local where possible.

It was because i tried to split a string within an array.

I transferred the contents through regular string and it works!

Elements of the Array class are typed as Object, a variant type that doesn’t know String methods. But since .Net [Split][1] returns an array of Strings instead of an Array instance, you could just use String instead of the problematic Array class:

...
var shops: String[] = myText.Split('*'[0]);
for (i = 0; i < shops.length; i++) {
  var graphics: String[] = shops*.Split(','[0]);*


NOTE: It’s a good practice to always declare variable types explicitly in Unity - untyped variables may fall in the Object class, causing lots of errors like the ones you had. The variable type may also be declared implicitly, by initializing it with the right value:
var myText = “”; // Unity infers that myText is String
var iii = 0; // iii is deduced to be an int (no decimals)
var floatVar = 0.0; // floatVar is considered float due to the decimal dot
[1]: String.Split Method (System) | Microsoft Learn