Forum Xamarin.Forms
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.

How to add dependency to android app which i am developing thruogh xamarin forms xamarin forms ?

As, we add dependency to build.gradle in android studio. Same how we can add dependency to android app in xamarin forms . I want to add this library by the dependency

dependencies {
compile 'com.squareup.sdk:register-sdk:1.0'

Please Reply ???


  • Patil2421Patil2421 USMember ✭✭✭
    edited September 2016

    I am assuming you want to use dependency services, in case you want this here is something you can try with this example:

    1. Create a interface
      public interface INetworkHandler
      HttpClientHandler GetNetworkHandler();

    2. Create a handler file in your Droid project
      [assembly: Xamarin.Forms.Dependency(typeof(NetworkHandler))]
      namespace Project.Droid
      public class NetworkHandler : INetworkHandler
      public HttpClientHandler GetNetworkHandler()
      return new System.Net.Http.HttpClientHandler
      Proxy = CoreFoundation.CFNetwork.GetDefaultProxy(),
      UseProxy = true

    3. Use it anywhere from the forms like this
      var networkHandler = Xamarin.Forms.DependencyService.Get<INetworkHandler>();

    You can make it work like this for iOS also

  • KaranveerSinghKaranveerSingh USMember ✭✭

    Thanks for reply, I am not asking about dependency service. See i want to use square card reader device in my app so for that i have to include a library for that square device to communicate with device. So, there is a way to install library through android studio but there is no way to install that library through xamarin forms . So, if you can please help

  • DannyPhamDannyPham USMember ✭✭✭

    @KaranveerSingh : you can use this plugin to add your dependency

Sign In or Register to comment.