Closed PrimaelQuemerais closed 5 months ago
Hi @PrimaelQuemerais !
Thanks for reaching out about this. The fact it only crashes in release mode it is quite interesting. From the logs it seems it's crashing as a result of a Null Pointer Exception and seems that strlen was called on a null pointer.
One of the places I could see your Flutter code sending a string would be on that testFile.path could you check if it's somehow null on release?
Could you also confirm if you are providing the proper permissions in Android?
Thanks again for reaching out and thanks in advance for the details,
Hello @CodeMinion
Thank you very much for the quick reply. Here are some additional information.
These are the permissions in my AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE"/>
I checked if testFile.path returns the correct value and it does, in my case:
/data/user/0/com.example.package/cache/test_print.png
I also checked if the file contains any data using testFile.readAsBytesSync() and it does yield the correct list of bytes.
I'm also experiencing the same issue when using the printFiles() function. And as stated before none of this happens in debug or profil, very strange.
Hello @PrimaelQuemerais ,
Thanks for the additional details. It's quite odd you are only seeing it in release. Normally that would make me think something is getting lost as part of minimify or proguard. Though looking at the logs it seems to originate from getCustomPaperCommand which in turn calls sendLogWithLevelV3 and that makes the native call to Java_com_brother_ptouch_sdk_JNIWrapper_sendLogToGlobalLoggingV3JNI with a null string. All these call are happening on the Brother SDK so that's a bit tricky.
In the case with the printFile and printFileList they all send the path directly to the native library so it would not surprise me if we are seeing it in both.
Could you try printing without using the custom paper and see if you still see the crash? I am curious if it's related to that or something else entirely.
Thanks again for all your help,
Good news!
As you suggested I tried to comment this line in my brotherPrinter() function :
Printer brotherPrinter() {
Printer printer = Printer();
PrinterInfo printInfo = PrinterInfo();
printInfo.printerModel = Model.TD_2120N;
printInfo.printMode = PrintMode.FIT_TO_PAGE;
printInfo.isAutoCut = false;
printInfo.port = Port.NET;
/*printInfo.customPaperInfo = CustomPaperInfo.newCustomDiaCutPaper(
Model.TD_2120N, Unit.Mm, 51, 26, 2, 2, 3, 3, 0);*/
printInfo.ipAddress = ip;
printInfo.binCustomPaper = BinPaper_TD2120N.RD_W51H26mm;
printer.setPrinterInfo(printInfo);
return printer;
}
And now my app is printing without any issue in Release. Would you like me to run some more tests in order to determine the reason behind this error?
Hello @PrimaelQuemerais ,
That's great news! Apologies for the delayed reply. Glad to hear it's working well on release.
Thank you for the offer for additional tests! With your original report I'll forward it to Brother during the hackathon taking place around April/May of this year and see if they know what it is or perhaps something they have a fix for by now.
Thanks again for all your help with this.
Hello, I'm running into an issue using this library. Everything works perfectly in Debug and Profil releases however my application force closes when building a Release version.
I'm getting no error on the Flutter side but here's the code that's likely to cause the crash :
And the brotherPrinter() function (This has been tested and works as expected) :
Here's the stacktrace from add logcat :
This is running on a Samsung Galaxy Tab A8 running Android 13. I can provide more information and run more tests if needed. Thank you very much for your help!