“Type or namespace Box2D could not be found” on An

2019-09-10 23:38发布

问题:

Im building a simple game with Xamarin/Cocossharp in a Shared Project. I added some physics with Box2D and everything works well on WP8.1.

I import Box2D and i access to the methods and class provided without problem on Windows Phone, but when i try to compile it for Android it says that the type or namespace "Box2D" could not be found. Intellisense doesn't shows any error...

error output

I'm new to game dev and also to VS2015 so it may be something simple but i dont understand what I'm missing here.

Thanks in advance

回答1:

After struggling around with this i managed to fix this:

As pointed out from Sven-Michael in his answer the solution was to install:

CocosSharp.PCL.Shared 

from NuGet. In my case was only necessary to add the reference to the Box2D.DLL file contained into the package.

The reason why it was not working for me it's probably that because of trying to solve this problem I've messed up whit my solution and caused other problems. So I created a new Project from skratch and I've imported my source code again.



回答2:

Ensure that you have installed CocosSharp.PCL.Shared to your Android project.

E.g. via PM-Comsole:

 Install-Package CocosSharp.PCL.Shared

But it can be installed via NuGet, too. This will add box2d and some other dependencies automatically.