Search code examples
c#xamarinadmobmonogame

How can I use Google Admob in a shared project?


I'm developing a mobile game for iOS and Android and I want to use Google Admob on both platforms.

I created an iOS project, an Android project and a Shared project in the solution explorer in Visual Studio and I added a reference from the iOS project to the shared project and a reference from the Android project to the shared project.

Now I need this nuget package for iOS so that Admob works on iOS, but I don't know if I need to add the nuget package in the iOS project or the Shared project.

nuget package

Where should I add the nuget package?

In addition, where(in which project?) should I add the AdManager class? Which part of the code should be in the iOS/Android project and which part of the code should be better in the Shared project?

I need to use this code for Admob: Admob Tutorial Code on github

picture


Solution

  • First you need to understand the difference between Shared & .Net Project. Shared projects only take reference from other projects and you cannot add any NuGet package in them, whereas in .Net projects, they have the separate dll's for every package.

    You can write the whole code in Shared project and you can add the NuGet package only in Android and iOS project.