Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Type has an extra field of type in the player and thus can't be serialized error

Discussion in 'Android' started by adamt, Sep 28, 2017.

  1. adamt

    adamt

    Joined:
    Apr 1, 2014
    Posts:
    116
    I'm getting intermittent errors on our build machine due to serialization issues. It's strange that it only seems to happen on Android builds on our Windows build machine (not iOS builds on our macOS build machine). It occurs when we build AssetBundles to save into StreamingAssets folder of the binary. The error looks like this:

    Type '[Assembly-CSharp]DungeonCrawler.Client.PVPHubPopup' has an extra field 'rewardProgressLabel' of type 'TMPro.TextMeshProUGUI' in the player and thus can't be serialized (expected 'attackLogTabButton' of type 'UnityEngine.UI.Button')

    Fields serialized in Editor, class 'DungeonCrawler.Client.PVPHubPopup'
    'playerNameLabel' of type 'TMPro.TextMeshProUGUI'
    'playerLevelLabel' of type 'TMPro.TextMeshProUGUI'
    'playerRankingLabel' of type 'TMPro.TextMeshProUGUI'
    'attackLogTabButton' of type 'UnityEngine.UI.Button'
    'defenseLogTabButton' of type 'UnityEngine.UI.Button'
    'battleLogContainer' of type 'UnityEngine.Transform'
    'battleLogEntryPrefab' of type 'UnityEngine.GameObject'

    Fields serialized in target platform, class 'DungeonCrawler.Client.PVPHubPopup'
    'playerNameLabel' of type 'TMPro.TextMeshProUGUI'
    'playerLevelLabel' of type 'TMPro.TextMeshProUGUI'
    'playerRankingLabel' of type 'TMPro.TextMeshProUGUI'
    'rewardProgressLabel' of type 'TMPro.TextMeshProUGUI'
    'attackLogTabButton' of type 'UnityEngine.UI.Button'
    'defenseLogTabButton' of type 'UnityEngine.UI.Button'
    'battleLogContainer' of type 'UnityEngine.Transform'
    'battleLogEntryPrefab' of type 'UnityEngine.GameObject'


    I've searched the forums and beyond (Stack Overflow, etc.) for answers but none of them seem to apply to us. Specifically:
    • We do not use partial classes;
    • We do not have serialized fields inside preprocessor directives;
    • We set the "-buildTarget android" flag on each invocation of the build
    The files complained about are also different -- it's not always the same file. I've tried removing the Library folder on the build machine to no avail. Is there something weird with the way
    BuildPipeline.BuildAssetBundles() works? We're just passing in the StreamingAssets directory, ChunkBasedCompression as an option, and BuildTarget.Android as the target.

    Re-running the build after the failure will put the build back into the correct state, but I'm not sure what system is getting put into an incorrect state in the first place.

    Any ideas? I'd like to file a bug but it's tough to reproduce because it relies not only on our project but also our Jenkins build machine and its job configuration.
     
    PhilMB likes this.
  2. BeorGames

    BeorGames

    Joined:
    Jul 28, 2018
    Posts:
    61
    Hello, same error here, I built the game yesterday, but after some improvements today, everything that I changed now comes with this msg on build...
     
    JoeStrout likes this.
  3. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,841
    I'm running into this same issue now — trying to build Android (for Quest) from macOS. Unity 2019.3 doesn't seem to support copying console messages as text, but here's a screenshot:

    upload_2020-4-15_10-1-38.png

    This makes no sense to me. Since when is a TextMeshProUGUI reference not serializable?
     
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,841
    Ugh... yes, it appears to be an intermittent Unity bug. After running in the editor, then I was able to build. Sheesh.
     
    koriball and chad47 like this.
  5. chad47

    chad47

    Joined:
    Dec 17, 2015
    Posts:
    4
    This worked for me, thank you!
     
  6. leventalpsal

    leventalpsal

    Joined:
    Apr 10, 2015
    Posts:
    6
    This bug still exists in 2019.3.9 Tried many times with no luck. The error message was pointing an enum that was in a class. I moved that enum out of the class. Tried again and it worked, it built successfully. Then I reverted that changed and moved the enum back in class. It built successfully again! Note: Build target : Windows x86_64
     
  7. Quardis

    Quardis

    Joined:
    Apr 16, 2016
    Posts:
    2
    Hey what do you mean by running in the editor?
     
    StellarVeil likes this.
  8. gnaveen

    gnaveen

    Joined:
    Apr 8, 2017
    Posts:
    1
    just remove the unity UI package and install it again
     
  9. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,875
    This is still present in unity 2022.1.20 and extremely irritating to work around.
     
    stonstad and JesseSTG like this.
  10. JesseSTG

    JesseSTG

    Joined:
    Jan 10, 2019
    Posts:
    236
    I'm seeing this, too.
     
  11. timchen214

    timchen214

    Joined:
    Dec 22, 2015
    Posts:
    6
    I'm seeing this too in 2022.1.17f1, just added a bool in the class, then I'm unable to sterilize asset bundle
     
  12. ducklmg

    ducklmg

    Joined:
    Aug 5, 2015
    Posts:
    1
    I have resolved this issue by deleting 'Library/Bee' and 'Library/BuildPlayerData' folders before run build script.
    (in Unity 2022.1.14)
     
  13. hxhloveunity

    hxhloveunity

    Joined:
    May 27, 2022
    Posts:
    32
    it work!!!
     
  14. timchen214

    timchen214

    Joined:
    Dec 22, 2015
    Posts:
    6
    This is the best solution, thank you so much
     
  15. StellarVeil

    StellarVeil

    Joined:
    Aug 31, 2018
    Posts:
    73
    Thanks it worked (2022.2.0f).
     
  16. LinnPeder

    LinnPeder

    Joined:
    Jul 6, 2022
    Posts:
    3
    Getting this error in Unity 2022.2.6f1
    Tried the following, which did not work:
    • Deleting Bee and BuildPlayerData
    • Deleting Library
    • Reimport All
    • Reinstalling Editor
    I don't know what to do from here.
     
    mc_fragezeichen likes this.
  17. mc_fragezeichen

    mc_fragezeichen

    Joined:
    Aug 17, 2020
    Posts:
    10
    I have similar issues using Unity 2022.2.6f1. There are no issues when building asset bundles from GUI but from command line weird errors occur. Deleting Bee and BuildPlayerData causes the entire command line build to fail (GUI builds are still working)
     
  18. PhilMB

    PhilMB

    Joined:
    Oct 3, 2022
    Posts:
    1
    Any news on this? I have this issue too and it completely breaks our automated builds
     
  19. WilB

    WilB

    Joined:
    Oct 25, 2012
    Posts:
    17
    Yep that was it! How truly obscure...
     
  20. esanuriana08

    esanuriana08

    Joined:
    Jan 10, 2021
    Posts:
    13
    I feel this might be a bug, but for some reason, there isn't clear information confirming whether this is indeed a bug or not. As a temporary solution, I managed to resolve the issue by deleting the 'Library/Bee' and 'Library/BuildPlayerData' directories. This approach worked for me
     
  21. CosmicStud

    CosmicStud

    Joined:
    Jun 13, 2017
    Posts:
    55
    For my project, I was on a Mac, still in PC/Mac/Standalone mode, attempting to run a build script for an Android build. It would fail due to the player having different scripts, which I think means the Oculus build scripts perform android only configurations to the build, being in the wrong platform will cause a mismatch. Switching platforms to Android then running the build script did the trick!