Quantcast
Channel: Questions in topic: "android sdk"
Viewing all articles
Browse latest Browse all 455

Android build problem when I clear app data?

$
0
0
I made a mini mobile game that has many scenes (each level in the game is a scene). the levels start from scene number 1 but there is a scene number 0 which contains an empty that has a script attached to it "Level0". public class Level0 : MonoBehaviour { public int levelIndex; public IEnumerator delayCoroutine() { yield return new WaitForSeconds(1f); SceneManager.LoadSceneAsync(levelIndex); } void Awake() { levelIndex = SaveLoadManager.loadCurrentLevelIndex(); StartCoroutine(delayCoroutine()); } } the role of this script is to call a static function from "SaveLoadManager" which returns the next level index (scene index in the build settings). public static int loadCurrentLevelIndex() { if (File.Exists(Application.persistentDataPath + "/data.txt")) { BinaryFormatter bf = new BinaryFormatter(); FileStream stream = new FileStream(Application.persistentDataPath + "/data.txt", FileMode.Open); PlayerDataSerializable data = bf.Deserialize(stream) as PlayerDataSerializable; stream.Close(); return data.realCurrentLevel; } else { return 1; } } so the method gets the level index from the data file but if the file is not found it just returns "1". Now the problem is that when I build the game to my OPPO A73 with Android 10 and enter the app settings and choose"clear data" and reopen the game, then it crashes at level0. however when I do the same thing with Nokia 3 (Android 9) or Xiaomi Redmi Note 10 (Android 11) the game works fine and loads the first level as expected. I monitored the errors via Logcat in Android Studio but I didn't get any error from Unity. Is the problem with my OPPO device? because I got this error in Logcat: E/DispScene: [/data/oppo/multimedia/oppo_display_perf_list.xml]:open config fail Or with Android 10?

Viewing all articles
Browse latest Browse all 455

Trending Articles