[Closed] Unity IAP Plugin makes errors on PS4

Hello! I have a problem with Unity IAP. It appears in a real project, but I also reproduced this in a test project.

My actions are:

  • Create an empty project.
  • Switch to iOS (or any platform, supported by Unity IAP, I assume)
  • Enable IAP in services, import the plugin, open IAP Demo, add the scene in the build settings.
  • Run the scene or make a build. Everything works fine and no errors.
  • Switch to PS4.

Then, I’ve got the problems. If I run the scene, it works, but I get errors:

  • FileNotFoundException: Could not load file or assembly ‘UnityEngine.Purchasing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies.

  • System.MonoCustomAttrs.GetCustomAttributesBase (ICustomAttributeProvider obj, System.Type attributeType) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/MonoCustomAttrs.cs:108)*

  • System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/MonoCustomAttrs.cs:151)*

  • System.MonoType.GetCustomAttributes (System.Type attributeType, Boolean inherit) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/MonoType.cs:595)*

  • UnityEngine.AttributeHelperEngine.CheckIsEditorScript (System.Type klass) (at C:/buildslave/unity/build/Runtime/Export/AttributeHelperEngine.cs:131)*

  • FileNotFoundException: Could not load file or assembly ‘UnityEngine.Purchasing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies.

  • System.Reflection.MonoMethodInfo.GetMethodInfo (IntPtr handle) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:59)*

  • System.Reflection.MonoMethodInfo.GetAttributes (IntPtr handle) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:75)*

  • System.Reflection.MonoMethod.get_Attributes () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:245)*

  • System.Reflection.MethodBase.get_IsSpecialName () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:184)*

  • UnityEditor.Build.BuildPipelineInterfaces.InitializeBuildCallbacks (Boolean findBuildProcessors, Boolean findSceneProcessors) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:149)*

And, if I try to make a build, I get:

  • FileNotFoundException: Could not load file or assembly ‘UnityEngine.Purchasing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies.
  • System.Reflection.MonoMethodInfo.GetMethodInfo (IntPtr handle) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:59)*
  • System.Reflection.MonoMethodInfo.GetAttributes (IntPtr handle) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:75)*
  • System.Reflection.MonoMethod.get_Attributes () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:245)*
  • System.Reflection.MethodBase.get_IsSpecialName () (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Reflection/MethodBase.cs:184)*
  • UnityEditor.Build.BuildPipelineInterfaces.InitializeBuildCallbacks (Boolean findBuildProcessors, Boolean findSceneProcessors) (at C:/buildslave/unity/build/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:149)*
  • UnityEditor.HostView:OnGUI()*
  • Error building Player: FileNotFoundException: Could not load file or assembly ‘UnityEngine.Purchasing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ or one of its dependencies.

And build wasn’t made.
So, I’ve found some workarounds, but they have disadvantages:

  • Delete the plugin (UnityChannel and UnityPurchasing folders). No plugin, no problems =)
  • Go through all DLLs in these folders and turn off each of them for Editor and PS4. I assume it helps, because some of these DLLs (for example, UnityPurchasing\Bin\Editor.dll) have reference to UnityEngine.Purchasing, that not available on PS4.

But there are problems: if I switch back to iOS platform, I’ll have to revert these changes. I think I can write a script, that will automatically make appropriate changes on a platform’s chaging. But if I write it, I’ll get unnecessary changes in my version control tool (Git), when I work on PS4.

Is there an other more convenient solution?

Hi vilinHc,

I feel your frustration.

Go through all DLLs in these folders and turn off each of them for Editor and PS4. I assume it helps, because some of these DLLs (for example, UnityPurchasing\Bin\Editor.dll) have reference to UnityEngine.Purchasing, that not available on PS4.

You should be able to do this and then wrap any platform specific stuff up with

#if <platform_define>
#endif

I’ll also chat with our IAP team to see if there could be an easier way to do this.

Thank you, I hope it exists.

@VilinHc Unfortunately we do not have an easier way to do this, but is on our longer term roadmap. We generally recommend to our users to make a separate build for console support, and disable IAP. Understood this is not ideal.

Ok, thank you.