Question by
Kostishko · Aug 05, 2021 at 12:57 PM ·
android buildlistsscript error
AoT lists, and lists which I made with Bolt doesn't work on device, but fine work in Editor.
Hello, I update project to new unity version for publish project in google play, and before that all works fine, and in editor, and on device.
But now all work only in editor, and lists stop working on device. Can someone help me, may be your seen that before?
I took logs from device, and get that exeption:
08-04 13:25:26.257 7766 7917 W Unity : Deserialization Failure Data
08-04 13:25:26.257 7766 7917 W Unity :
08-04 13:25:26.257 7766 7917 W Unity : Object References:
08-04 13:25:26.257 7766 7917 W Unity : (None)
08-04 13:25:26.257 7766 7917 W Unity :
08-04 13:25:26.257 7766 7917 W Unity : JSON:
08-04 13:25:26.257 7766 7917 W Unity : {
08-04 13:25:26.257 7766 7917 W Unity : "declarations": {
08-04 13:25:26.257 7766 7917 W Unity : "collection": {
08-04 13:25:26.257 7766 7917 W Unity : "$content": [
08-04 13:25:26.257 7766 7917 W Unity : {
08-04 13:25:26.257 7766 7917 W Unity : "name": "BallStrikeSaved",
08-04 13:25:26.257 7766 7917 W Unity : "value": {
08-04 13:25:26.257 7766 7917 W Unity : "$content": 0,
08-04 13:25:26.257 7766 7917 W Unity : "$type": "System.Int32"
08-04 13:25:26.257 7766 7917 W Unity : },
08-04 13:25:26.257 7766 7917 W Unity : "$version": "A"
08-04 13:25:26.257 7766 7917 W Unity : },
08-04 13:25:26.257 7766 7917 W Unity : {
08-04 13:25:26.257 7766 7917 W Unity : "name": "ScoreCountSaved",
08-04 13:25:26.257 7766 7917 W Unity : "value": {
08-04 13:25:26.257 7766 7917 W Unity : "$content": 0,
08-04 13:25:26.257 7766 7917 W Unity : "$type": "System.Int32"
08-04 13:25:26.257 7766 7917 W Unity : },
08-04 13:25:26.257 7766 7917 W Unity : "$version": "A"
08-04 13:25:26.257 7766 7917 W Unity : },
08-04 13:25:26.257 7766 7917 W Unity : {
08-04 13:25:26.257 7766 7917 W Unity : "name": "RecordsCountList",
08-04 13:25:26.257 7766 7917 W Unity : "value": null,
08-04 13:25:26.257 7766 7917 W Unity : "$version": "A"
08-04 13:25:26.257 7766 7917 W Unity : },
08-04 13:25:26.257 7766 7917 W Unity : {
08-04 13:25:26.257 7766 7917 W Unity : "name": "RecordsList",
08-04 13:25:26.257 7766 7917 W Unity : "value": {
08-04 13:25:26.257 7766 7917 W Unity : "$content": [
08-04 13:25:26.257 7766 7917 W Unity : 0.0,
08-04 13:25:26.257 7766 7917 W Unity : 0.0,
08-04 13:25:26.257 7766 7917 W Unity :
08-04 13:25:26.287 7766 7917 E Unity : Failed to deserialize scriptable object.
08-04 13:25:26.287 7766 7917 E Unity : System.Runtime.Serialization.SerializationException: Deserialization into 'Bolt.VariablesAsset' failed. ---> System.InvalidOperationException: Constructor of System.Collections.Generic.List`1[System.Single] threw an exception when creating an instance ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'System.Collections.Generic.List<System.Single>' threw an exception. ---> System.ExecutionEngineException: Attempting to call method 'System.Collections.Generic.List`1[[System.Single, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]::.cctor' for which no ahead of time (AOT) code was generated.
08-04 13:25:26.287 7766 7917 E Unity : at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00000] in <00000000000000000000000000000000>:0
08-04 13:25:26.287 7766 7917 E Unity : at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [
08-04 13:25:26.446 7766 7917 E Unity : InvalidOperationException: Variable not found: 'RecordListAot'.
Comment
Answer by Kostishko · Aug 05, 2021 at 09:43 PM
Well, I think I solved this. How I understood - problem was in new SDK Android version. Lists now work with json format (doesn't know how exactle). I found on github packages "Json.NET 10.0.3 for Unity" and add to project (just in files, not on scenes) c# script. All it's working now:
using Newtonsoft.Json.Utilities;
using UnityEngine;
public class AotTypeEnforcer : MonoBehaviour
{
public void Awake()
{
AotHelper.EnsureList<int>();
}
}