我正在使用Xamarin.Android处理Brother标签打印机QL-710W。
我创建了一个Android绑定项目,并添加了jar文件和.so文件,如下所示。
我正在使用Visual Studio。
罐子>
NativeLibraries> armeabi>
附加 ClassTest.cs
public bool PrintFile(string fileurl, NetPrinter printer)
{
Task <bool> printTask = new Task<bool>(() => {
bool success = true;
try
{
Printer myPrinter = new Printer();
PrinterInfo myPrinterInfo = new PrinterInfo();
PrinterStatus status = new PrinterStatus();
LabelInfo mLabelInfo = new LabelInfo();
myPrinterInfo.PrinterModel = PrinterInfo.Model.Ql710w;
myPrinterInfo.IpAddress = printer.IpAddress;
myPrinterInfo.MacAddress = printer.MacAddress;
myPrinterInfo.Port = PrinterInfo.PortEnum.Net;
myPrinterInfo.PrintMode=PrinterInfo.PrintModeEnum.FitToPage;
myPrinterInfo.PaperSize = PrinterInfo.PaperSizeEnum.Custom;
myPrinterInfo.Orientation = PrinterInfo.OrientationEnum.Portrait;
myPrinterInfo.LabelNameIndex = LabelInfo.QL700.W62.Ordinal();
myPrinterInfo.ScaleValue = 1;
mLabelInfo.LabelNameIndex = LabelInfo.QL700.ValueOf("W62").Ordinal();
mLabelInfo.IsAutoCut = true;
mLabelInfo.IsEndCut = true;
myPrinter.SetPrinterInfo(myPrinterInfo);
myPrinter.SetLabelInfo(mLabelInfo);
myPrinter.StartCommunication();
status = myPrinter.PrintFile(fileurl);
if (status.ErrorCode != PrinterInfo.ErrorCode.ErrorNone)
success = false;
myPrinter.EndCommunication();
}catch(Exception ex)
{
Console.WriteLine("ERROR : {0}",ex.Message);
success = false;
}
return success;
});
printTask.Start();
var isSuccess = printTask.Result;
return isSuccess;
}
我正在从网络上成功获得打印机列表。但是当我调用上面的方法时,它会在 myPrinter.SetPrinterInfo(myPrinterInfo); 中获得异常,因为 “无法从loader dalvik.system.PathClassLoader [DexPathList []加载createdata [zip file \“/ data / app / PocAndroidArchieve.PocAndroidArchieve-2.apk \”],nativeLibraryDirectories = [/ data / app-lib / PocAndroidArchieve.PocAndroidArchieve-2,/ vendor / lib,/ system / lib]]]: findLibrary返回null“
如果有人有想法使用jar和依赖的.so文件,请建议我。
提前致谢。