JNI 在 Brother SDK 上检测到应用错误

Iam*_*Dev 4 java printing android android-ndk brother-bpac

我试图在我的应用程序的 Brother SDK 中打印图像。

这是我的代码:

       `myPrinterInfo = myPrinter.getPrinterInfo();
        myPrinterInfo.printerModel = PrinterInfo.Model.QL_810W;
        myPrinterInfo.port = PrinterInfo.Port.NET;
        myPrinterInfo.printMode = PrinterInfo.PrintMode.FIT_TO_PAGE;
        myPrinterInfo.paperSize = PrinterInfo.PaperSize.CUSTOM;
        myPrinterInfo.labelNameIndex = 5;
        myPrinterInfo.isAutoCut = false;
        myPrinterInfo.isCutAtEnd = false;
        myPrinterInfo.orientation = PrinterInfo.Orientation.PORTRAIT;
        myPrinterInfo.valign = PrinterInfo.VAlign.TOP;
        myPrinterInfo.align = PrinterInfo.Align.LEFT;
        myPrinterInfo.halftone = PrinterInfo.Halftone.THRESHOLD;
        myPrinterInfo.ipAddress = "192.168.1.146";
        myPrinterInfo.thresholdingValue = 127;
        myPrinterInfo.pjCarbon = false;
        myPrinterInfo.pjDensity = 5;
        myPrinterInfo.pjFeedMode = PrinterInfo.PjFeedMode.PJ_FEED_MODE_FIXEDPAGE;
        myPrinterInfo.pjPaperKind = PJ_CUT_PAPER;
        myPrinterInfo.rollPrinterCase = PrinterInfo.PjRollCase.PJ_ROLLCASE_OFF;
        myPrinterInfo.paperPosition = PrinterInfo.Align.CENTER;
        myPrinterInfo.numberOfCopies = 1;
Run Code Online (Sandbox Code Playgroud)

我使用的是 62mmx100mm 纸卷,但收到此错误消息:

JNI 在应用程序中检测到错误:GetStringUTFChars 收到 NULL jstring 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art:调用 GetStringUTFChars 08-10 17:33:131538382 .com.squarebits.brothertest E/art:来自 boolean com.brother.ptouch.sdk.JNIWrapper.writeByteInFile(int[], int, java.lang.String, boolean) 08-10 17:33:18.882 31333-31584/ br.com.squarebits.brothertest E/art: "AsyncTask #1" prio=5 tid=10 Runnable 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: | group="main" sCount=0 dsCount=0 obj=0x12c99460 self=0xe9594500 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: | sysTid=31584 nice=10 cgrp=bg_non_interactive sched=0/0 handle=0xe0b65930 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art:| state=R schedstat=( 80462688 29252686 258 ) utm=5 stm=3 core=2 HZ=100 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest | stack=0xe0a63000-0xe0a65000 stackSize=1038KB 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: | 持有互斥锁 =“mutator 锁”(共享持有) 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: native: #00 pc 0035adcf /system/lib/libart.so (_ZN3artative__stream_18.882) +126) 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: 原生: #01 pc 0033bdeb /system/lib/libart.so (_ZNK3art6Thread4DumpEENSt3_113c10_stream_1135840033333bdeb/system/lib/libart.so (_ZNK3art6Thread4DumpEENSt1_stream_113c8c000000000000000000000000000000033bdeb/system/lib/libart.so) 33:18.882 31333-31584/br.com.squarebits.brothertest E/art: native: #02 pc 0024ef71 /system/lib/libart.so ( 33:18.882 31333-31584/br.com.squarebits.brothertest E/art: | stack=0xe0a63000-0xe0a65000 stackSize=1038KB 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: | 持有互斥锁 =“mutator 锁”(共享持有) 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: native: #00 pc 0035adcf /system/lib/libart.so (_ZN3artative__stream_18.882) +126) 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: 原生: #01 pc 0033bdeb /system/lib/libart.so (_ZNK3art6Thread4DumpEENSt3_113c10_stream_1135840033333bdeb/system/lib/libart.so (_ZNK3art6Thread4DumpEENSt1_stream_113c8c000000000000000000000000000000033bdeb/system/lib/libart.so) 33:18.882 31333-31584/br.com.squarebits.brothertest E/art: native: #02 pc 0024ef71 /system/lib/libart.so ( 33:18.882 31333-31584/br.com.squarebits.brothertest E/art: | stack=0xe0a63000-0xe0a65000 stackSize=1038KB 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: | 持有互斥锁 =“mutator 锁”(共享持有) 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: native: #00 pc 0035adcf /system/lib/libart.so (_ZN3artative__stream_18.882) +126) 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: 原生: #01 pc 0033bdeb /system/lib/libart.so (_ZNK3art6Thread4DumpEENSt3_113c10_stream_1135840033333bdeb/system/lib/libart.so (_ZNK3art6Thread4DumpEENSt1_stream_113c8c000000000000000000000000000000033bdeb/system/lib/libart.so) 33:18.882 31333-31584/br.com.squarebits.brothertest E/art: native: #02 pc 0024ef71 /system/lib/libart.so ( | stack=0xe0a63000-0xe0a65000 stackSize=1038KB 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: | 持有互斥锁 =“mutator 锁”(共享持有) 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: native: #00 pc 0035adcf /system/lib/libart.so (_ZN3artative__stream_18.882) +126) 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: 原生: #01 pc 0033bdeb /system/lib/libart.so (_ZNK3art6Thread4DumpEENSt3_113c10_stream_1135840033333bdeb/system/lib/libart.so (_ZNK3art6Thread4DumpEENSt1_stream_113c8c000000000000000000000000000000033bdeb/system/lib/libart.so) 33:18.882 31333-31584/br.com.squarebits.brothertest E/art: native: #02 pc 0024ef71 /system/lib/libart.so ( | stack=0xe0a63000-0xe0a65000 stackSize=1038KB 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: | 持有互斥锁 =“mutator 锁”(共享持有) 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: native: #00 pc 0035adcf /system/lib/libart.so (_ZN3artative__stream_18.882) +126) 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art: 原生: #01 pc 0033bdeb /system/lib/libart.so (_ZNK3art6Thread4DumpEENSt3_113c10_stream_1135840033333bdeb/system/lib/libart.so (_ZNK3art6Thread4DumpEENSt1_stream_113c8c000000000000000000000000000000033bdeb/system/lib/libart.so) 33:18.882 31333-31584/br.com.squarebits.brothertest E/art: native: #02 pc 0024ef71 /system/lib/libart.so (ZN3art9JavaVMExt8JniAbortEPKcS2 +900) 08-10 17:33:18.882 31333-31584/br.com.squarebits.brothertest E/art:本机:#03 pc 0024f607 /system/lib/ZNbort39tA15Jnbort3PKc5JVA_list39tAPK15JVA_list39t9tA/system/libZNbort39t9tA_18.882 31333-31584/br.com.squarebits.brothertest E/art :33:18.882 31333-31584/br.com.squarebits.brothertest E/art: native: #04 pc 000fbe5d /system/lib/libart.so (_ZN3art11ScopedCheck6AbortFEPKcz+28) 08-10: 181538332 br.com.squarebits.brothertest E/art:本机:#05 pc 001003b9 /system/lib/libart.so (_ZN3art11ScopedCheck5CheckERNS_18ScopedObjectAccessEbPKcPNS_12JniValueTypeE.constprop.95+2676) 07:100333/13833/13833.13833.13833.so (_ZN3art11ScopedCheck5CheckERNS_18ScopedObjectAccessEbPKcPNS_12JniValueTypeE.constprop.95 squarebits.brothertest E/art: native: #06 pc 00108cd5 /system/lib/libart.so (_ZN3art8CheckJNI17GetStringUTFCharsEP7_JNIEnvP8_jstringPh+376)

如果有人知道如何解决它,请帮助我:(

小智 6

我今天遇到了类似的问题,事实证明未授予 android.permission.WRITE_EXTERNAL_STORAGE 权限。如果您运行的是 Android 6 或更高版本,请检查您的运行时权限以写入外部存储。在清单中声明权限是不够的。兄弟文档在他们的手册末尾暗示了这一点。

8.3. Android 6 兼容性 从 Android 6.0 开始,用户可以在安装后更改应用程序的权限。必须授予访问 Android 外部存储的权限才能使用此应用程序。