- Home /
Android APK freezes during level load but not in Unity Editor
I'm building a mobile game for android, and i've gotten pretty far with no issues. My scenes were loading properly and everything was working fine on both the Unity Editor and the Android APK until recently. I have a "Loading Page" transition into every scene. My game starts off with a splash scene, then loads to the transition "Loading Page" and then to the "Main Page". On both the Unity Editor and the Android APK, these all load fine. In my "Main Page", i have a "Start" button, which when clicked, it loads the "Game Page". In the Unity Editor, when i press the "Start" button everything runs smoothly and it loads perfectly fine. When i build the Android APK and try pressing the "Start" button on mobile, it takes me to the transition "Loading Page" no problem, but then just freezes and never loads the "Game Page". This has only started happening recently, and i have not made that many changes to my game. I went as far as to start a whole new project from scratch and building it all again and starting from today the issue has started again. I am using Photon Network, and thought that maybe that was the issue due to me just recently getting Unity_2017. I removed all Photon Network scripts and all assets from my project and loaded all scenes offline through SceneManager.LoadAsync, and am still getting the same issue.. I've tried loading other scenes other than the "Game Page" after the transition "Loading Page" but still the same issue. I removed all 3D objects from my scenes and even went as far as to removing all 3D objects from the project entirely.
I am confused as to what is going on here. If someone has some kind of answer to this or some way i can try to resolve this it would be greatly appreciated!!!! Please help!!
This is the code i am using to transition from scene to scene through the "Loading Page" :
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; using UnityEngine.EventSystems;
public class LoadingText : MonoBehaviour {
private AsyncOperation ao;
private int levelToLoad;
private string lastLoadedScene;
// Use this for initialization
IEnumerator Start () {
lastLoadedScene = getLastLoadedScene.getLastLevel ();
if (lastLoadedScene == "SplashNameLoad") {
levelToLoad = 2;
}
else if (lastLoadedScene == "Main") {
levelToLoad = 3;
}
ao = SceneManager.LoadSceneAsync (levelToLoad);
ao.allowSceneActivation = false;
GetComponent<Text> ().text = "Loading";
yield return new WaitForSeconds (0.5f);
GetComponent<Text> ().text = "Loading.";
yield return new WaitForSeconds (0.5f);
GetComponent<Text> ().text = "Loading..";
yield return new WaitForSeconds (0.5f);
GetComponent<Text> ().text = "Loading...";
yield return new WaitForSeconds (0.5f);
GetComponent<Text> ().text = "Loading..";
yield return new WaitForSeconds (0.5f);
GetComponent<Text> ().text = "Loading.";
yield return new WaitForSeconds (0.5f);
GetComponent<Text> ().text = "Loading";
ao.allowSceneActivation = true;
}
}
@clunk47 Can you help with this, I am having same issue
@hexagonius can you help with this, I am having same issue :)
What's the list of levels added in the build list in player settings? Can you also create a debug build, attach your phone or whatever to the computer with USB cable and run "adb logcat -s Unity" in your console? It should spit out information about the running game.
In my build list it goes :
splashNameLoad : 0 loadingPage : 1 mainPage : 2 gamePage : 3
on my main page, i call it to load the "loadingPage" by its build number. Which then transitions to the "gamePage" by it's build number as well.
I've also ran the adb logcat and filtered out for just Unity logs, and it shows nothing but my click or touch events. No errors at all... Even when it holds still (frozen) on the "loadingPage". It does however, still log my clicks or touches even after it freezes.
while (!ao.isDone)
{
yield return null;
}
Debug.Log(string.Format("additive load {0} completed", lvl2load));
Do your asyncOperation ever respond isDone?
Hm, i'm assu$$anonymous$$g so since it works and fires fine in the Editor? I tried to keep my code as simple as possible and not add any while loops but i guess i'll try this to see if it is firing in the Android Build.
Update :
while (!ao.isDone) { yield return null; } Debug.Log(string.Format("additive load {0} completed", levelToLoad));
This seems to not fire properly even in the editor. Seems to get stuck in the while loop and never come out of it. When i remove the while loop and just add the Debug.Log, it works and fires the log fine and all level loads in the Editor. $$anonymous$$obile device is still having the same issue.
Update :
<i>AndroidPlayer(samsung_S$$anonymous$$-G928W8@192.168.2.10)</i> Unloading 6 Unused Serialized files (Serialized files now loaded: 0)
The above message comes up after i load into the "$$anonymous$$ain Page". It unloads everything basically, which is fine and i expected that. I then tap my button to load the "Loading Page", it loads fine. But then freezes when trying to load the "Game Page" and spits out this log message in the console :
>AndroidPlayer(samsung_S$$anonymous$$-G928W8@192.168.2.10)</i> Unloading 0 Unused Serialized files (Serialized files now loaded: 0)
It's not loading anything! Even though in my script it loads fine in the Editor, it just doesn't want to load anything on the Android device... This makes no sense to me.. Oh, and this log just constantly keeps spitting out endlessly until i close the app.
Those logs might happen on some devices in debug mode, might be related to huge Ressource.Load() calls.. That's probably why it's stuck on loading. It is difficult to figure it out without seeing the part of your project responsible for this issue you are having. If while(!async.isDone) doesn't break it means it is stuck on loading something.
Answer by Jay1234 · Aug 21, 2017 at 02:20 AM
I resolved and figured out the problem two nights actually, and it was exactly what you just mentioned. I had a Resources.load call running in the Update on a script in my "Main Page" without even realizing it. I definitely did not mean to plug it in there, but guess it got in there anyway lol. Just made it so difficult to find since no errors were pumping out and it was loading fine in the Editor. But once i removed the resources.load call from the Update everything ran smoothly again on mobile. I'll mark and accept your answer @adrienPlayerium since you technically had the right one even though you responded after it was resolved, appreciate your answer!
@$$anonymous$$1234 thank you :D Sorry I couldn't help you in time ~ I got offline this weekend ~ Cheers glad you fixed it!
in my case i still having this issue in android. i tested all the advises you mentioned ...
Answer by AnisimovArthur · Feb 25, 2020 at 07:52 AM
Hey,
In my case the problem was in a camera in a scene. I change 'Target Eye' to none (main display) and 'clear flags' to Skybox.
Hope it will help!
Your answer
Follow this Question
Related Questions
My game is working not in android build as it works in the editor 0 Answers
android app dont start on device after inistalation 2 Answers
My simple shader not working correctly on Android 0 Answers
Why an Android build doesnt make a _Data file. 1 Answer
Input Fields not actually taking in user data on android build 0 Answers