Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on GoogleMobileAdsSettings #3371

Open
victor-kallai opened this issue May 15, 2024 · 2 comments
Open

Error on GoogleMobileAdsSettings #3371

victor-kallai opened this issue May 15, 2024 · 2 comments
Assignees
Labels
Support General question, Installation question, or feedback.

Comments

@victor-kallai
Copy link

[REQUIRED] Step 1: Describe your environment

  • Unity version: All
  • Google Mobile Ads Unity plugin version: 9.1.0
  • Plugin installation method: Both (Unity package manager, .unitypackage import)
  • Platform: iOS, Android (iOS, Android, Unity Editor)
  • Platform OS version: All (eg iOS 10, Android 9)
  • Any specific devices issue occurs on: All
  • Mediation ad networks used, and their versions: None

[REQUIRED] Step 2: Describe the problem

Steps to reproduce:

Create an empty project, import GoogleMobileAds plugin and add the GoogleMobileAdsSettings to the Preloaded Assets list in the Project Settings.
When running the build on an Android or iOS device I get this error in the console:

A scripted object (probably GoogleMobileAds.Editor.GoogleMobileAdsSettings?) has a different serialization layout when loading. (Read 56 bytes but expected 100 bytes) Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?

The error is harmless and more of a nuisance, than an actual critical issue.

The problem is that the GoogleMobileAdsSettings class file is in an Editor folder (which gets stripped out at build time) and GoogleMobileAdsSettings scriptable object file is in a normal Resources folder (so this gets included in the build).

Proposed solutions

  1. Move the GoogleMobileAdsSettings scriptable object file in the EditorDefaultResources folder. Problem with this is that there can only be one EditorDefaultResources folder per project and it needs to be at the root (it can't be inside GoogleMobileAds folder)

  2. Move the GoogleMobileAdsSettings class file outside the Editor folder. It will require to create a new Assembly Definition file for it.

@NVentimiglia
Copy link
Member

@victor-kallai why are you adding the Editor file to the Preloaded Assets? This file is used during building to write configurations to the plist / android manifest and is not intended to be loaded at runtime.

@NVentimiglia NVentimiglia self-assigned this May 21, 2024
@NVentimiglia NVentimiglia added the Support General question, Installation question, or feedback. label May 21, 2024
@victor-kallai
Copy link
Author

Adding the Editor file to the Preloaded Assets is just a quick way to expose and test the error, without any additional steps.

In my original project I have a plugin (Reflex) which is calling the UnityEngine.Resources.LoadAll when the project is first loaded, using this annotation [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)].

The error in that case is this:

A scripted object (script unknown or not yet loaded) has a different serialization layout when loading. (Read 56 bytes but expected 164 bytes)
                 Did you #ifdef UNITY_EDITOR a section of your serialized properties in any of your scripts?
                 UnityEngine.Resources:LoadAll(String)
                 Reflex.Core.CreateProjectContainer:Create()
                 Reflex.Injectors.UnityInjector:BeforeAwakeOfFirstSceneOnly()

This is a bit more ambiguous, it's not clear which scripted object is to blame.

To test the same thing, you can add a script that calls Resources.Load(path); in a static method with [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Support General question, Installation question, or feedback.
Projects
None yet
Development

No branches or pull requests

2 participants