Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Project does not recognize references library

FranGilFranGil USMember
edited November 2016 in Xamarin.Android

Hi, I have a project "TestProject" and a library "TestLib", the project reference my library and it works perfectly.
Currently I've installed "nugget Google Ads" on "TestProject", it works!

Now I want the nugget of "Google Ads" doesn't belong to the project and belong to my library.
Thus, any of my projects that uses my library include "Google Ads".

I deleted nuggets "Google Ads" from "Test Project" and I added this in "TestLib", BUT it doesn't work...
How should I do it?
I received errors about not finding resources and now the last error that says something like:

The type or namespace name 'Gms' does not exist in the namespace 'Android' (are you missing an assembly reference?) TestProject.Droid

Answers

  • JohnMillerJohnMiller USForum Administrator, Xamarin Team Xamurai

    @FranGil,

    It sounds like TestLib is a project included in the same solution as TestProject. If that's true, then I expect the following:

    • You can reference the NuGet package in TestLib and use it's API with no issue.
    • You cannot use any API from that NuGet package in TestProject because it does not have a direct reference to the package.
    • If you want to use GoogleAds in TestProject, you need to add the NuGet package to that project too.

    The NuGet in TestLib only covers use in TestLibs source.

  • FranGilFranGil USMember

    Thank you for answering so quickly @John !

    I don't understand why I can't add a nugget to "TestLib" and use it directly in "TestProject", because "TestProject" can use all the classes that I've created in "TestLib".

    For example, on Android Studio I had this same case and it worked.
    "TestLib" also included my classes, several libs like GoogleAds, GoogleAnalytics...
    And "TestProject" import "TestLib" and I could use all it.

  • JohnMillerJohnMiller USForum Administrator, Xamarin Team Xamurai

    @FranGil,

    I am not familiar enough with Java and AndroidStudio to know how that works in comparison. However, take a look at this question which has a few answers that I think help explain now .NET works.

Sign In or Register to comment.