Android Question BrotherSDK2B4A problem

mc73

Well-Known Member
Licensed User
Longtime User
I really don't know what's going on, though I suspect I did something wrong with the placement of 'so' files.

I used 'simpleLibraryCompiler (1.01)' and then I added just a void to perform printing. Lib is loaded, but upon run I get
B4X:
java.lang.UnsatisfiedLinkError: Couldn't load createdata from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/b4a.example-2.apk"],nativeLibraryDirectories=[/data/app-lib/b4a.example-2, /vendor/lib, /system/lib]]]: findLibrary returned null
   at java.lang.Runtime.loadLibrary(Runtime.java:358)
   at java.lang.System.loadLibrary(System.java:526)
   at com.brother.ptouch.sdk.PrinterModel.<clinit>(PrinterModel.java:30)
   at com.brother.ptouch.sdk.Communication.createPrinterModel(Communication.java:275)
   at com.brother.ptouch.sdk.ComNet$CommunicationThread.run(ComNet.java:473)

Seems that a lib is missing, though I've added the brotherLib to both the additional folder of b4a and of my workspace. Yet, I'm not sure about the 'so' files.

The code of void goes like this, just in case anyone sees something wrong:

B4X:
package biz.logismic;
import com.brother.ptouch.sdk.*;

import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.*;

@Version(3.0f)
@ShortName("BrotherPrintSDK")
@DependsOn(values={"BrotherPrintLibrary"})
public class brotherSDK {
   
   public void print(String filePath,String printerIP,String macAddress){
     
     Printer myPrinter = new Printer();
     PrinterInfo myPrinterInfo = new PrinterInfo();
     PrinterStatus printResult = new PrinterStatus();
     LabelInfo mLabelInfo=new LabelInfo();
     try{
     
       myPrinterInfo = myPrinter.getPrinterInfo();
       myPrinterInfo.printerModel=PrinterInfo.Model.QL_710W;
       myPrinterInfo.printMode=PrinterInfo.PrintMode.FIT_TO_PAGE;
       myPrinterInfo.port=PrinterInfo.Port.NET;
       myPrinterInfo.paperSize = PrinterInfo.PaperSize.CUSTOM;
       myPrinterInfo.orientation = PrinterInfo.Orientation.PORTRAIT;
       myPrinterInfo.numberOfCopies = 1;
       myPrinterInfo.ipAddress=printerIP;
       myPrinterInfo.macAddress=macAddress;
     
       mLabelInfo.labelNameIndex=LabelInfo.QL700.valueOf("W62").ordinal();
       mLabelInfo.isAutoCut = true;
       mLabelInfo.isEndCut =true;
       
       myPrinter.setPrinterInfo(myPrinterInfo);
       myPrinter.setLabelInfo(mLabelInfo);
       printResult=myPrinter.printFile(filePath);
     } catch(Exception e){   
     }}}

I'm almost sure, there is a simple solution, but can't figure it out :)
 

mc73

Well-Known Member
Licensed User
Longtime User
You should move the so file under the location specified in a post above:
The problem was with the location of 'so' file. I had it under 'additional', but I had to add the 'lib' subdirectory under 'additional' first
I really don't know of other cause. However, I notice you used the 720 model. I used this model in the past, and there was no need for an SDK. I simply used to send ESC POS commands directly to the printer.
 
Upvote 0

buras3

Active Member
Licensed User
Longtime User
i don't know how to do that and i spend so much time to fix this lib
is this where the so files need to be ?
SimpleLibraryCompiler\BrotherSDK\libs\additional\lib
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

buras3

Active Member
Licensed User
Longtime User
I did every thing possible 100 times , it's just wont work
now i get android.os.networkonmainthreadexception
i added
<code>
'If p.SdkVersion >= 9 Then
' Dim r As Reflector
' r.Target = r.CreateObject("android.os.StrictMode$ThreadPolicy$Builder")
' r.Target = r.RunMethod("permitAll")
' r.Target = r.RunMethod("build")
' r.RunStaticMethod("android.os.StrictMode", "setThreadPolicy", _
' Array As Object(r.Target), Array As String("android.os.StrictMode$ThreadPolicy"))
'End If
</code>
now i get error from the lib ERROR_CONNECT_SOCKET_FAILED

do someone knows how to fix this ?
 
Upvote 0
Top