Application.loadlevelasync problem in android devices

Hi, im trying to do a loading screen with Application.loadlevelasync, but my android game is crashing when loading (in the editor it has no problem) this is my code, i don`t know if there is to much to load in a device or i have problems in my code.

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class loadingScreen : MonoBehaviour {
public GameObject barra;
public Text textoCarga;
bool iniciarLoad;

// Use this for initialization

void Update () {
if (!iniciarLoad) {
StartCoroutine (loading());
iniciarLoad=true;
}

}
IEnumerator loading(){

AsyncOperation asynx = Application.LoadLevelAsync (1);

while(asynx.isDone == false){
barra.transform.localScale = new Vector2 (asynx.progress,barra.transform.localScale.y);
textoCarga.text = "Loading " + (int)(asynx.progress * 100) + “%”;

yield return null;

}
}
}

Hi namda,

It could be down to the processing speed of your android device.

void Update () {
if (!iniciarLoad) {
StartCoroutine (loading());
iniciarLoad=true;
}

This is possibly the culprit. Change it for:

void Update () {
if (!iniciarLoad) {
iniciarLoad=true;
StartCoroutine (loading());
}

That’s not definitely the reason, but it helps with processing speed safety. Another thing to consider is moving it from the Update() function. Are you going to using this function so many times that it needs to be in Update()? Maybe it being in start will make sure it’s only ever run once :). Just a suggestion. :).

So instead it would be:

void Start () {
if (!iniciarLoad) {
iniciarLoad=true;
StartCoroutine (loading());
}