Read now

Integrating EPSON POS (Model TM-*** ) Printer with your android application

In this blog we will learn how to integrate EPSON POS Printer (Model starting with TM )with your android application.

Integrating this is not at all difficult, if you follow the steps correctly.

First, download the Epson sdk for android. (You can download the sdk from here).
Now from this package, extract the ePOS2.jar file and paste it in your libs folder.

Add this line in your build.gradle file.

Now all you have to do is make an object of the Printer and set the content that you want to print.
Lets have a look on how to do that.

createMyData()

printMyData()

Please note that in printMyData(), you need to replace the first input with the target i.e you need to set the path of the connection or more specifically the port address of your printer.

That’s all
You can connect the printer and test it yourself.

 

. . .

Comments (8)

Add Your Comment

  • Gabriel Savio
    How I get “REPLACE_THIS_STRING_WITH_THE_PORT_CONNECTION” ?
    • anchit
      Hello Gabriel,

      Basically it is the target port of the connected printer.

      Before you request to print data you need to save the connected printer information with you and then from that information the value of the target filed needs to be passed in this function.

  • Darshan Bhatt
    I am getting following error

    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file “/data/app/com.cmexpertise.instaorder-hogeXAYNRK-s_ihRSPwlBQ==/base.apk”],nativeLibraryDirectories=[/data/app/com.cmexpertise.instaorder-hogeXAYNRK-s_ihRSPwlBQ==/lib/arm64, /system/lib64, /product/lib64]]] couldn’t find “libepos2.so”

    • anchit
      Hello Darshan,

      It seems that you have not multidex enabled in your project.

      Once you enable the proguard in your project then you will have to do a trick with your code.

      In the “jniLibs” directory of your project.

      There will be one directory named “armeabi” or some other directory that contains a file named “libepos.so”

      When you find this file then you need to take a copy of this file and make five directories under the “jniLibs” directory.

      The names of these directories should be exactly :
      arm64-v8a
      armeabi
      armeabi-v7a
      x86
      x86_64

      In each of these directories, paste the “libepos.so” file in each of these directories.

      Your final code should look like something like this –> http://i.prntscr.com/3vNb-25ySfKFWgfVWYRGnA.png

      Hope this helps you.
      If still, you are facing any issue, then please do let me know.

  • Zandro Zulueta
    I bought an EpsonTMU220-B with a USB port recently. I want my android application to do printing like what you mentioned here. Is it possible to do this with the hardware I bought or should I have an printer with the ethernet at the back instead of the usb port?
    • anchit
      Yes, it is possible to print with the hardware you bought.

      You just need to make sure that your android device and the printer are connected via the usb port .
      You will need to make sure that the printer and android device are connected and in sync before giving any print command as explained in the blog above.

      • Zandro Zulueta
        hi achit, thanks for the reply. I downloaded the sample Java program which comes form the Epson android sdk which is called ePOS2 Printer sample app. The app makes a sample printout of a receipt.
        I downloaded the Java code to my Mac OS laptop, loaded it in android studio and installed it in my phone. I then connected the TMU220B to the USB port of a router and connected my phone to that router. It will not print..
        So I went to the epson dealer and asked for a TMU220B with an internet port (not USB) and plugged that printer to my router. I then connected my phone to the same router and fixed the router settings to allow 192.168.192.168. This time I was able to print a receipt!

        Am I correct to say that this TMU220 USB printer will only work with a Window computer that has the epson hardware driver and will not work if I connect it to a network router

  • Zandro Zulueta
    Separate question, would you have directions on how to set up for Android studio in Mac? What I have been reading so far online is using Eclipse in Windows
  • css.php
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again
    Close