I'm using ZXing library to generate QR codes, and I'm trying to set MARGIN
property to 1 by this way:
Map<EncodeHintType, Object> hintMap = new EnumMap<EncodeHintType, Object>(EncodeHintType.class);
hintMap.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hintMap.put(EncodeHintType.MARGIN, 1); // java.lang.NoSuchFieldError: MARGIN
hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.Q);
QRCodeWriter qrCodeWriter = new QRCodeWriter();
BitMatrix byteMatrix = qrCodeWriter.encode(contents, BarcodeFormat.QR_CODE, 100, 100, hintMap);
But I'm getting java.lang.NoSuchFieldError: MARGIN
. I'm using 2.3.0 version:
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>2.3.0</version>
</dependency>
I also examined EncodeHintType.class with Eclipse, and MARGIN property is there! I don't understand what's happening.
Any help will be appreciated, thanks in advance!
Inspired by this answer, I discovered that I had installed on Tomcat server two different versions of this library: core-2.0
and core-2.3.0
. My code was using at runtime 2.0 version instead of 2.3.0.
I removed core-2.0.jar
from Tomcat, and now it's working! :)