Generate qr code in

Youssef 46 Reputation points

I have a problem generating qr code. I used a sample from site:

But I got a null reference error at this line:
bitmapMatrix = new MultiFormatWriter().encode(message, BarcodeFormat.QR_CODE, size, size);

In my project I have installed the next packages:

  • Xamarin.AndroidX.AppCompat
  • Xamarin.Essentials
  • Xamarin.Google.Android.Material

Does anyone have a clue why I am getting a null reference?

Gr. Youssef

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,293 questions
{count} votes

Accepted answer
  1. JarvanZhang 23,936 Reputation points

    Hello yaza,​

    Welcome to our Microsoft Q&A platform!

    The ZXing.Net API may not perform well on Android. Try using ZXing.Net.Mobile nuget instead, which is a mobile-specific. I've tested the function code with this package, it works as expected. The nuget requires the Xamarin.AndroidX.Legacy.Support.V4 dependency, please install the package for your project.

    Best Regards,

    Jarvan Zhang

    If the response is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful