Unable to generate QR code using Aspose Barcode

We are unable to generate QR code using Aspose.BarCode in Java.

The code line throwing error is below:

com.aspose.barcode.generation.BarcodeGenerator generator = new com.aspose.barcode.generation.BarcodeGenerator(com.aspose.barcode.EncodeTypes.QR, "My sample text");

And the exception being caught is below:

Exception data: java.lang.NoClassDefFoundError: android.graphics.Typeface

Please suggest solution to the problem.

Thanks.

@mussab,

Which version of Aspose.BarCode for Java you are using? Please try using newer version of the product. I tested using the following sample code in a simple console application, it works fine and the output image is generated (attached) fine:
e.g
Sample code:

// Instantiate BarcodeGenerator object
com.aspose.barcode.generation.BarcodeGenerator generator = new com.aspose.barcode.generation.BarcodeGenerator(com.aspose.barcode.EncodeTypes.QR, "My sample text");
		
// Set the error level
generator.getParameters().getBarcode().getQR().setQrErrorLevel(QRErrorLevel.LEVEL_Q);

// Set the QR barcode version number
generator.getParameters().getBarcode().getQR().setQrVersion(com.aspose.barcode.QRVersion.VERSION_12);

// Save the image
generator.save("f:\\files\\qr_version12QR1.png");

qr_version12QR1.png (3.0 KB)

@Amjad_Sahi

I have the following aspose barcode dependency added in pom.xml which I believe is the latest one https://downloads.aspose.com/barcode/java.

<dependency>
	<groupId>com.aspose</groupId>
	<artifactId>aspose-barcode</artifactId>
	<version>20.8</version>
</dependency>

And the application is deployed on WebSphere 8.5.5.14.

@Amjad_Sahi

The issue has been resolved by adding jdk17 classifier in the aspose barcode dependency

<dependency>
	<groupId>com.aspose</groupId>
	<artifactId>aspose-barcode</artifactId>
	<version>20.8</version>
	<classifier>jdk17</classifier>
</dependency>

@mussab,
Good to know that your issue is sorted out. Feel free to contact us any time if you need further help, we will be happy to assist you soon.