1. 程式人生 > >解決Type mismatch: cannot convert from ByteMatrix to BitMatrix

解決Type mismatch: cannot convert from ByteMatrix to BitMatrix

問題背景: 微信支付時,生成二維碼使用的是zxing 

BitMatrix bitMatrix = new MultiFormatWriter().encode(code_url,
					BarcodeFormat.QR_CODE, width, height, hints); //Type mismatch: cannot convert from ByteMatrix to BitMatrix

報錯在於encode方法返回是 ByteMatrix 型別不能轉換

解決步驟: 檢視encode原始碼找到其引用的jar包


引用的是zxing.jar 其package為 com.google.zxing.common.ByteMatrix 與 core2.3.jar包 com.google.zxing.common.BitMatrix;路徑相近這裡包引入錯誤,刪除zxing.jar引入core2.3.jar即可