Android version behaves differently

Hi guys

No idea what is going on but atm, my program won’t run on my mobile. I put a debug output text and it displays me the correct values when run on the PC but still the uninitialized value when run on Android. This is the code of my “debugger” (btw if anyone could give me a pointer to “how to debug on mobile” thatll be great):

public class NaiveDebugger : MonoBehaviour {

    GameManager mgr;
    HUDManager hudMgr;
    Text myText;

    void Start () {
        mgr = GameObject.Find ("GameManager").GetComponent<GameManager>();
        hudMgr = GameObject.Find ("HUDManager").GetComponent<HUDManager>();
        myText = GetComponent<Text>();
    }

    void Update () {
        myText.text = hudMgr.storyHUD.activeSelf + "!" + mgr.enabled + "!";
    }
}

This is attached to an object in the second scene which is loaded after I click a button. But this object will only have its text displayed as the initial value I gave it via the editor. It doesn’t show true or false or anything else. It used to work a few weeks ago and I can’t see anything that may have to do with this behavior, but I experienced this once but it then disappeared.

My god-class is the GameManager which owns every other Manager. The managers and relevant objects are not destroyed on scene change, at least not on PC. I assume an exception being thrown at some point very early on which I cannot see (since I dont know how to debug mobile).

Please tell me if you need any additional information and thanks for your help in advance.

I noticed that when loading the second scene my Managers will be gone. This only happens on Android and I have no idea why and where to search for this.

Now I got my adb running, producing the following output, which sadly doesn’t give me any new information:

01-01 14:55:57.765 6022 6039 I Unity : I am the GameManager, still being alive
01-01 14:55:57.765 6022 6039 I Unity : UnityEngine.Debug:Internal_Log(Int32, String, Object)
01-01 14:55:57.765 6022 6039 I Unity : UnityEngine.Debug:Log(Object)
01-01 14:55:57.765 6022 6039 I Unity : GameManager:changeToScene(Int32) (at E:\Eigene Dateien\Unity\Assets\scripts\GameManager.cs:236)
01-01 14:55:57.765 6022 6039 I Unity : UnityEngine.Events.InvokableCall1:Invoke(Object[ ]) 01-01 14:55:57.765 6022 6039 I Unity : UnityEngine.Events.CachedInvokableCall1:Invoke(Object[ ])
01-01 14:55:57.765 6022 6039 I Unity : UnityEngine.Events.InvokableCallList:Invoke(Object[ ])
01-01 14:55:57.765 6022 6039 I Unity : UnityEngine.Events.UnityEventBase:Invoke(Object[ ])
01-01 14:55:57.765 6022 6039 I Unity : UnityEngine.Events.UnityEvent:Invoke()
01-01 14:55:57.765 6022 6039 I Unity : UnityEngine.UI.Button:Press() (at C:\BuildAgent\work\d63dfc6385190b60\Extensions\guisystem\guisystem\UI\Core\Button.cs:35)
01-01 14:55:57.765 6022 6039 I Unity : UnityEngine.UI.Button:OnPointerClick(PointerEventData) (at C:\BuildAgent\work\d63dfc6385190b60\Extensions\guisystem\guisystem\UI\Core\Button.cs:44)
01-01 14:55:57.765 6022 6039 I Unity : UnityEngine.EventSystems.ExecuteEvents:Execute(IPointerClickHandler, BaseEventData) (at C:\BuildAgent\work\d63dfc6385190b60\Extensions\guisystem\guisystem\EventSystem\ExecuteEvents.cs:52)
01-01 14:55:57.765 6022 6039 I Unity : UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`
01-01 14:55:57.812 6022 6044 D Unity : WARNING: DXT texture format is not supported, decompressing texture
01-01 14:55:57.961 6022 6044 D Unity : WARNING: DXT texture format is not supported, decompressing texture
01-01 14:55:58.054 6022 6044 D Unity : WARNING: DXT texture format is not supported, decompressing texture
01-01 14:55:58.133 6022 6044 D Unity : WARNING: DXT texture format is not supported, decompressing texture
01-01 14:55:58.203 6022 6044 D Unity : WARNING: DXT texture format is not supported, decompressing texture
01-01 14:55:58.359 6022 6039 D Unity : UnloadTime: 35.002998 ms
01-01 14:55:58.453 6022 6039 D Unity : System memory in use before: 14.2 MB.
01-01 14:55:58.469 6022 6039 D Unity : Unloading 4 Unused Serialized files (Serialized files now loaded: 0 / Dirty serialized files: 0)
01-01 14:55:58.469 6022 6039 D Unity : System memory in use after: 12.0 MB.
01-01 14:55:58.469 6022 6039 D Unity :
01-01 14:55:58.469 6022 6039 D Unity : Unloading 172 unused Assets to reduce memory usage. Loaded Objects now: 354.
01-01 14:55:58.469 6022 6039 D Unity : Total: 14.069000 ms (FindLiveObjects: 0.305000 ms CreateObjectMapping: 0.122000 ms MarkObjects: 2.869000 ms DeleteObjects: 5.706000 ms)
01-01 14:55:58.469 6022 6039 D Unity :
01-01 14:55:58.500 6022 6039 I Unity : GameMgr is gone now
01-01 14:55:58.500 6022 6039 I Unity : UnityEngine.Debug:Internal_Log(Int32, String, Object)
01-01 14:55:58.500 6022 6039 I Unity : UnityEngine.Debug:Log(Object)
01-01 14:55:58.500 6022 6039 I Unity : NaiveDebugger:Start() (at E:\Eigene Dateien\Unity\Assets\scripts\NaiveDebugger.cs:26)
01-01 14:55:58.500 6022 6039 I Unity :
01-01 14:55:58.500 6022 6039 I Unity : (Filename: E Line: 0)
01-01 14:55:58.500 6022 6039 I Unity :
01-01 14:55:58.508 6022 6039 I Unity : Update
01-01 14:55:58.508 6022 6039 I Unity : UnityEngine.Debug:Internal_Log(Int32, String, Object)
01-01 14:55:58.508 6022 6039 I Unity : UnityEngine.Debug:Log(Object)
01-01 14:55:58.508 6022 6039 I Unity : NaiveDebugger:Update() (at E:\Eigene Dateien\Unity\Assets\scripts\NaiveDebugger.cs:39)
01-01 14:55:58.508 6022 6039 I Unity :
01-01 14:55:58.508 6022 6039 I Unity : (Filename: E Line: 0)
01-01 14:55:58.508 6022 6039 I Unity :
01-01 14:55:58.508 6022 6039 I Unity : GameMgr is gone now
01-01 14:55:58.508 6022 6039 I Unity : UnityEngine.Debug:Internal_Log(Int32, String, Object)
01-01 14:55:58.508 6022 6039 I Unity : UnityEngine.Debug:Log(Object)
01-01 14:55:58.508 6022 6039 I Unity : NaiveDebugger:Start() (at E:\Eigene Dateien\Unity\Assets\scripts\NaiveDebugger.cs:26)
01-01 14:55:58.508 6022 6039 I Unity : NaiveDebugger:Update() (at E:\Eigene Dateien\Unity\Assets\scripts\NaiveDebugger.cs:40)
01-01 14:55:58.508 6022 6039 I Unity :
01-01 14:55:58.508 6022 6039 I Unity : (Filename: E Line: 0)
01-01 14:55:58.508 6022 6039 I Unity :
01-01 14:55:59.992 432 460 V AlarmManager: sending alarm Alarm{41ad4fd0 type 3 android}
01-01 14:56:01.242 432 442 D ConnectivityService: getMobileDataEnabled returning false

This log is between the scene change. Two debuggers each report that the GameManager doesn’t exist anymore.

Motorola RAZR MAXX Systemversion 982.124.14.XT910.Retail.en.EU
Android version 4.1.2
Buildnr 9.8.2O-124_SPUEM-14

Please help me :frowning:

Using a script that only does “DontDestroyOnLoad(gameObject)” leads to the object not being destroyed. Still not further with my investigations

Kind of got it now. The error is thrown even before the scene change. It has to do with the path where I store my images. It works on PC but not on Android since the paths are different.
The error is

DirectoryNotFoundException: Directory ‘/storage/sdcard0/Android/data/de.xy.MyGame/files/images/gestures’ not found.

The files folder exists. but there is nothing in it. Why and how can I change that? On my comp, the files exist in
E:\Eigene Dateien\Unity\Assets\images\gestures

The code to set the path is

    public virtual void Start () {
        mgr = FindObjectOfType<GameManager>();
        castMgr = FindObjectOfType<CastManager>();
        gestMgr = FindObjectOfType<GestureManager>();
        if(Application.platform == RuntimePlatform.Android){
            dataPath = Application.persistentDataPath;
        } else if(Application.platform == RuntimePlatform.WindowsPlayer){
            dataPath = Application.dataPath;
        } else if (Application.platform == RuntimePlatform.WindowsEditor){
            dataPath = Application.dataPath;
        }
    }

How can I tell Unity that when building the apk I want to refer to the contents of this folder gestures?

#if UNITY_ANDROID
/* code */
#endif

That’s a good reference but I doon’t see how I can tell Unity when packaging that it should (in any case, I also need that when running on PC) copy the contents of a certain folder (which has files that are not used in scenes or in the editor).