使用Brother Android SDK WIFI打印QL-710W时遇ERROR_WRONG_LABEL错误
Fixing ERROR_WRONG_LABEL for Brother QL-710W Android SDK WiFi Printing
Hey there, let's tackle that frustrating ERROR_WRONG_LABEL issue you're hitting with your QL-710W. Since the official Brother app works perfectly, the problem almost certainly lies in how your SDK configuration is mismatched with the printer's expected settings. Let's break this down and fix it step by step.
Key Issues in Your Current Code
Looking at your code, there are a couple of conflicting settings that are likely triggering the error:
- You've set
paperSize = PrinterInfo.PaperSize.CUSTOMwhile also specifying a standard label index (W50). QL series printers rely on the label name index to recognize standard label sizes, and setting a custom size overrides this, causing a mismatch. - Duplicate
isAutoCutsettings create redundant code that can lead to confusion, even if they don't directly cause the error. - Hardcoding the ordinal value might not be the most reliable way to target the right label size—we can make this more robust.
Revised Configuration Code
Here's a cleaned-up, corrected version of your code that aligns with how the official app would configure the printer:
// Initialize printer info with correct model and network settings mPrinterInfo.printerModel = PrinterInfo.Model.QL_710W; mPrinterInfo.port = PrinterInfo.Port.NET; mPrinterInfo.ipAddress = "192.168.8.100"; // Skip setting custom paper size—let the label index define the size mPrinterInfo.paperSize = PrinterInfo.PaperSize.UNKNOWN; mPrinterInfo.paperPosition = PrinterInfo.Align.CENTER; mPrinterInfo.orientation = PrinterInfo.Orientation.LANDSCAPE; // Use the standard W50 label index (match this to your actual label) mPrinterInfo.labelNameIndex = LabelInfo.QL700.W50.ordinal(); mPrinterInfo.isAutoCut = true; mPrinterInfo.isCutAtEnd = true; // Initialize label info to match printer settings exactly LabelInfo mLabelInfo = new LabelInfo(); mLabelInfo.labelNameIndex = LabelInfo.QL700.W50.ordinal(); mLabelInfo.isAutoCut = true; mLabelInfo.isEndCut = true; mLabelInfo.isHalfCut = false; mLabelInfo.isSpecialTape = false; // Apply the settings to the printer object mPrinter.setPrinterInfo(mPrinterInfo); mPrinter.setLabelInfo(mLabelInfo);
Additional Troubleshooting Tips
- Verify Your Physical Label: Double-check that the label loaded in your QL-710W is exactly the
W50(50mm wide continuous) label. If you're using a different size (like W62), update the label index to match. - Dynamically Fetch Supported Labels: Instead of hardcoding the ordinal value, use the SDK's built-in method to get the printer's supported label list. This ensures you're using the correct index for your specific printer:
// Get the list of labels your printer supports List<LabelInfo> supportedLabels = mPrinter.getLabelList(); // Find the W50 label in the list for (LabelInfo label : supportedLabels) { if ("W50".equals(label.labelName)) { mPrinterInfo.labelNameIndex = label.labelNameIndex; mLabelInfo.labelNameIndex = label.labelNameIndex; break; } } - Update the Brother SDK: Make sure you're using the latest version of the Brother Android SDK. Older versions might have compatibility bugs with the QL-710W that the official app has already fixed.
内容的提问来源于stack exchange,提问作者Siddhpura Amit
相关产品推荐
相关产品推荐

