0
\$\begingroup\$

I'm trying to install the Stripe API Library through NuGet Manager in Visual Studio but it installs it inside packages folder of the Project (I.E. before Project's Assets folder) doing this I cannot use the library:

Using UnityEngine;
Using Stripe; //Doesn't recognise this

Then I:

  • Moved those installed files from packages to Assets folder
  • Uninstalled Stripe from NuGet (as I could now access them in my script by using Stripe)

Now these are the main errors that I'm getting:

PrecompiledAssemblyException: Multiple precompiled assemblies with the same name Newtonsoft.Json.dll included for the current platform. Only one assembly with the same name is allowed per platform. Assembly path: {0}
Assembly 'Assets/Temp/lib/netstandard2.0/Stripe.net.dll' will not be loaded due to errors:
Unable to resolve reference 'System.Collections.Immutable'. Is the assembly missing or incompatible with the current platform?

Assembly 'Assets/Temp/lib/netstandard1.2/Stripe.net.dll' will not be loaded due to errors:
Unable to resolve reference 'System.Collections.Immutable'. Is the assembly missing or incompatible with the current platform?
\$\endgroup\$
2
\$\begingroup\$

It looks like stripe is / is using a precompiled c# dll. Whenever you have a precompiled dll in unity it should be located in a folder called Plugins. When you click on the dll file you can set the platform that it's built for. You need to compile the dll for each platform you plan to release on, then set the unity settings on the dll to tell unity that. The error you have above shows that there are already multiple dlls, but you haven't set them to their correct platform settings. I'm not familiar with stripe's nuget package, but I do recognize that unity error, and I've worked with stripe in other languages.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thanks, also I wanted to know if there's any other way to import libraries in unity, basically unity has its own package manager but stripe isn't available in unity package manager. So if i wanted to use something like paypal or stripe. How can include them and use them in the unity scripts. \$\endgroup\$ – Usama Zaheer Mar 18 '19 at 13:40
  • \$\begingroup\$ 3 Things to note here: 1. Any library that uses c# http will not function correctly when porting to consoles. Unity supports it's own http library and thus you likely will have to build your own API wrapper specifically for unity using it's http libraries. And event then consoles like the Switch make it impossible to send https requests to anything but a small handful of addresses. However for PC release you should be 100% fine, just be aware of the consequences should you plan to release on other platforms later. \$\endgroup\$ – gjh33 Mar 18 '19 at 13:53
  • \$\begingroup\$ 2. Any library can be imported if it uses unity's subset of the c# runtime. Unity isn't using c# like most applications use c#. It's only using the syntax. Unity has it's own compiler, that compiles a subset of c# into c++. So certain modern c# features aren't supported by unity, even if they use the same version of c# that unity supports. So some libraries just won't work, and there's not much you can do about it. \$\endgroup\$ – gjh33 Mar 18 '19 at 13:53
  • 1
    \$\begingroup\$ 3. You can do a lot with dlls including getting around some of the limitations of unity's subset of c#. Some google search will show you how to precompile c# programs into dlls using visual studio. If you have a library that you want to port into unity, this is probably a good solution. See the following doc docs.unity3d.com/Manual/UsingDLL.html \$\endgroup\$ – gjh33 Mar 18 '19 at 13:53
  • \$\begingroup\$ Thank you so much for showing me a direction. I will try understanding dlls first. \$\endgroup\$ – Usama Zaheer Mar 18 '19 at 14:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.