Forum Xamarin.Forms


The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Xamarin.Forms and Sharing a PCL with Android and iOS using Embeddinator


I'm a newbie to Xamarin, and I'm trying to setup a project that allows me to share .NET code between Android and iOS platforms. I tried following this guide: / visualstudio / share-ui-code-in-any-ios-and-android-app-with-net-embedding/

but I am running into a prroblem getting the PCL to build an AAR file for Android. I followed the guide okay and the build succeeds, soI have gotten to the point of running the after-build custom command using Embeddinator, but the command fails. The AfterBuild custom command I am running is this:

mono '${SolutionDir}/packages/Embeddinator-4000.0.4.0/tools/Embeddinator-4000.exe' '${TargetPath}' --gen=Java --platform=Android --outdir='${SolutionDir}/androidoutput' -c 'bin/Debug/FormsViewGroup.dll'

which returns the error

Could not find assembly 'bin/Debug/FormsViewGroup.dll'

I get the impression the FormsViewGroup DLL is supposed to exist, but I do not see one either. But the guide makes no mention of a ManagedAssembly or DLL, and I'm confused as to how to fix this. I don't work with .NET very often and I've never tried to embed a PCL in a native app before. Has anyone managed to embed a PCL shared library in native apps or does anyone know what I'm missing?

It is worth noting that the example/guide is running Xamarin.Forms 2.5 and I started a new PCL project with Xamarin.Forms version



  • xambambeefiusxambambeefius Member ✭✭

    I figured out the DLL issue. I'm just unfamiliar with .NET but the assembly should be 'SharedUI.dll' and is in the path [PROJECT_ROOT]/SharedUI/bin/CONFIGURATION(Debug or Release)/SharedUI.dll'.

    However, I still cannot get the Embeddinator to correctly run and package up Android and iOS importable versions of the Class Library called SharedUI that I've made for sharing pages and components across platforms.

    Has anyone had any luck getting shared ui code from PCL on mobile platforms?

  • xambambeefiusxambambeefius Member ✭✭

    I forgot to mention the error I have now that the paths and assembly references are correct:

    ** Unable to find NDK toolchain for Arm!**

    And for iOS:

    Cross compilation to target platform 'iOS' is not supported

    Which is confusing to me, because the embeddinator command itself lists both platforms Android and iOS, on Mac, as valid platforms to build for.

    Has anyone had luck embedding Xamarin.Forms SharedUI components or pages in native platform apps for iOS or Android?

    Any help would be appreciated!
    Thanks for your time.

  • Jack_HuaJack_Hua Member ✭✭✭

    Can you please follow the new document and try again?

  • xambambeefiusxambambeefius Member ✭✭

    Hey Jack.
    Thanks for getting back to me!

    Unfortunately, it looks like in those docs the links for Android and iOS both 404. I managed to get as far as building the PCLs, but when I run Embeddinator for either Android or iOS I get errors that I haven't been able to resolve yet. I'm not sure how to convert the DLL (SharedUI.dll) to an AAR or other file I can use in my native apps.

    I checked the GitHub page for Embeddinator, as well, but its own "getting started" link takes me to a Xamarin Tools documentation page that does not seem to mention embedding dotnet.

  • Jack_HuaJack_Hua Member ✭✭✭

    OK, I would recommend you to open an issue in the github and get more information.

    Also, have a look at this thread may help.

Sign In or Register to comment.