I cannot understand why I'm getting StackoverflowError. I'm trying to build bitmap from an image to scan QR code. source from decode() method is build in standard way:
if (bitmap != null) {
int[] intArray = new int[bitmap.getWidth() * bitmap.getHeight()];
bitmap.getPixels(intArray, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());
return new RGBLuminanceSource(bitmap.getWidth(), bitmap.getHeight(), intArray);
And than decode() throws error: source: Method threw 'java.lang'StackOverflowError' exception. Cannot evaluate com.google.zxing.RGBLuminanceSource.toString()
private QRCodeMultiReader qrCodeReader;
public void decode(LuminanceSource source, ScannerResultListener resultListener) {
try {
BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
String decodedContent = qrCodeReader.decode(bitmap, hints).getText();
Timber.d("qr code scanner has successfully decoded content: [%s]", decodedContent);
resultListener.onScanningSuccess(decodedContent);
} catch (ReaderException re) {
Timber.d(re.getMessage(), "qr code scanner can not decode code");
resultListener.onScanningFailure();
} finally {
qrCodeReader.reset();
}
}
It happens only when I upload image with big dimensions (e. g. 1242x2688px). When I downsize uploaded image to height for example 2160px, everything is ok., and image is scanned properly. I cannot find anything about zxing dimensional restrictions.
Does anybody know why is that?
Problem solved. I had to upgrade Zxing libs to newer version. In my problem 3.3.1 was sufficient. But newer libs require SDK 19+.