CustomRenderer from custom imported .aar and ios views

boris_dvboris_dv USMember ✭✭

Hi,

im working on an app in our company that is based on xamarin.forms. The problem that im trying to solve for a while now is that i have to import custom views (camera ocr) that we received from an external company (as .aar library). My idea is to create a binding library and then create a custom renderer that will use the imported UI views. Im looking for any useful information for a week now .. and the only thing i found out is that importing native libraries is pain .. :smiley:

So i have a few questions for experienced members ...

  1. Is my idea possible ? Can i import some complete native views ? (both android/ios) and use them using custom renderer in a .forms app ?
  2. If yes ... what is the best widget/view type in android to import from .aar (they created a Fragment , but i can ask them to change to something else ...)
  3. Are there any examples of something similar ? (not basic aar imports with one simple method that returns a string ...)
  4. We didnt received ios libraries yet ... any tips for ios native views binding ?

Thank you
Boris

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    You can binding this aar library, and use it in xamarin form.
    For more details, check: https://docs.microsoft.com/en-us/xamarin/android/platform/binding-java-library/binding-an-aar

    Besides, you can use DependencyService to invoke native platform functionality from shared code in Xamarin.Forms applications. For more details, you can check: https://docs.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/dependency-service/introduction

  • jezhjezh Member, Xamarin Team Xamurai

    Have you resolved your problem?

  • theRealShengtheRealSheng Member
    edited September 30

    Hello Jezh,
    Can you please advise if it is possible to render the view from native Java to Xamarin?

    I have created an aar library from a jar file in Java. Then I created a binding library in Xamarin. Within the same solution, I created a Xamarin Mobile project. I was able to call the library within the Android project, but I failed in rendering the view into app.

    I have been working for few days now and this is as far I was able to achieve. Could you please help me to see how can I fix this? I have sent you a private message with the project.

    Looking forward to your advise.

    Thank you in advance!

    I appreciate your time and consideration.

    Best regards,

    Sheng

Sign In or Register to comment.