Building for Android when using Odin through the package manager generate an error

Issue #758 new
Sylvain V. created an issue

Hello,

We added Odin to a Unity package, as described here. This is needed because some of our own packages are dependent from Odin.

If the package is added localy to our Unity project, using “Add package from disk” in the package manager, it doesn’t cause any issues. But if the package is uploaded to a scoped registry and downloaded through the package manager, an error occurs when building for Android.

The error is the following :

InvalidOperationException: Failed to get PluginImporter for Library\PackageCache\com.ohrizon.odin@3.0.1\Plugins\Sirenix\Assemblies\NoEmitAndNoEditor\Sirenix.Serialization.dll
Sirenix.Serialization.Utilities.Editor.AssemblyImportSettingsUtilities.SetAssemblyImportSettings (UnityEditor.BuildTarget platform, System.String assemblyFilePath, System.Boolean includeInBuild, System.Boolean includeInEditor) (at X:/Repositories/sirenix-development/OdinSerializer/OdinSerializer/Utilities/Misc/AssemblyImportSettingsUtilities.cs:207)
Sirenix.Serialization.Utilities.Editor.AssemblyImportSettingsUtilities.SetAssemblyImportSettings (UnityEditor.BuildTarget platform, System.String assemblyFilePath, Sirenix.Serialization.Utilities.Editor.OdinAssemblyImportSettings importSettings) (at X:/Repositories/sirenix-development/OdinSerializer/OdinSerializer/Utilities/Misc/AssemblyImportSettingsUtilities.cs:169)
Sirenix.OdinInspector.Editor.AssemblyImportSettingsAutomation.ApplyImportSettings (UnityEditor.BuildTarget platform, System.String[] assemblyPaths, Sirenix.Serialization.Utilities.Editor.OdinAssemblyImportSettings importSettings) (at Library/PackageCache/com.ohrizon.odin@3.0.1/Plugins/Sirenix/Odin Inspector/Scripts/Editor/AssemblyImportSettingsAutomation.cs:112)
Sirenix.OdinInspector.Editor.AssemblyImportSettingsAutomation.ConfigureImportSettings () (at Library/PackageCache/com.ohrizon.odin@3.0.1/Plugins/Sirenix/Odin Inspector/Scripts/Editor/AssemblyImportSettingsAutomation.cs:98)
Sirenix.OdinInspector.Editor.AssemblyImportSettingsAutomation.UnityEditor.Build.IPreprocessBuildWithReport.OnPreprocessBuild (UnityEditor.Build.Reporting.BuildReport report) (at Library/PackageCache/com.ohrizon.odin@3.0.1/Plugins/Sirenix/Odin Inspector/Scripts/Editor/AssemblyImportSettingsAutomation.cs:120)
UnityEditor.Build.BuildPipelineInterfaces+<>c__DisplayClass15_0.<OnBuildPreProcess>b__1 (UnityEditor.Build.IPreprocessBuildWithReport bpp) (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
UnityEditor.Build.BuildPipelineInterfaces.InvokeCallbackInterfacesPair[T1,T2] (System.Collections.Generic.List`1[T] oneInterfaces, System.Action`1[T] invocationOne, System.Collections.Generic.List`1[T] twoInterfaces, System.Action`1[T] invocationTwo, System.Boolean exitOnFailure) (at <8c48e4bc2ff34638b69095cbb65e2e27>:0)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun()

There is two different behaviour :

  • When using “build and run” the error is displayed and the apk is not built.
  • When using “build” the error is displayed and the apk is built.

We used the package system with Odin 2.1.6 and did not encountered this issue. The issue has been successfully reproduced with odin 3.0.1 and 3.0.4.

The issue has been reproduced with Unity 2020.2.6f1 and 2019.4.x, both installed on Windows 10.

“Editor Only Mode” is not enabled and can’t seem to be enabled when using a downloaded package. When trying to enable “Editor Only Mode” these errors are displayed :

I attached to this issue the Asset folder from the Unity project that holds Odin. If you want to reproduce the issue you will need your own unity package server.

Please let me know if you need more information!

Thanks :)

Comments (8)

  1. Francisco Mabres

    Hi @Sylvain V. We’ve found the same issue today, I can say that the main issue is this line in the serializer library.

    https://github.com/TeamSirenix/odin-serializer/blob/master/OdinSerializer/Utilities/Misc/AssemblyImportSettingsUtilities.cs#L182

    var importer = (PluginImporter)AssetImporter.GetAtPath(assemblyFilePath);
    if (importer == null)
    {
        throw new InvalidOperationException("Failed to get PluginImporter for " + assemblyFilePath);
    }
    

    When AssetImporter.GetAtPath tries to find a file that is outside of the /Assets folder then it will fail to retrieve the importer for that file.

    If using a git package or creating an embedded package (like us) and putting odin at /Packages this line will fail every single time.

    Hope they can resolve this as it interferes with our project structure.

  2. big soul

    AssemblyImportSettingsAutomation.cs

     var isPackage = true;// PathUtilities.HasSubDirectory(new DirectoryInfo(projectAssetsPath), new DirectoryInfo(assemblyDir)) == false;
    

  3. Former user Account Deleted

    Any updates, guys?

    The same problem for me with Odin 3.0.12.0 and Unity 2020.3.25f1.

  4. Tor Esa Vestergaard

    To clarify what is going on with this issue, Odin currently needs write access to its own install for several features to work, and so does not properly support being installed as a read-only package. Our best recommendation is to not install Odin in a package that is read-only, as several things can break. If you do want to do it, you must make certain to disable the Import Settings automation options under Tools > Odin > Preferences as import settings cannot be changed on assemblies in read only packages, and also refrain from attempting to toggle editor only mode, as this will not function either as there is no write access. Generating the AOT support .dll in the default path will not work either, and I have heard of occasional trouble generating various config assets as well.

    The main thing we can do here is provide better error messages for when these features are attempted used while Odin is installed in read-only mode, but this is not something we have focused on for now as we do not consider it a supported way of installing Odin. That, of course, should also be better clarified in the documentation - I will make sure to get that done.

  5. Sylvain V. reporter

    @Tor Esa Vestergaard If I understood correctly, using Odin in an embedded package should work because it is not read-only, right? I tried to test this solution, with unfortunately the same error when trying to build for Android.

  6. Log in to comment