2. How to add the library

2.1. Adding the library to project

Library supports Maven Repository and AAR file.Please link library that suits your application configuration.

Important

From SDK V5.17.1, StarIO and StarIOExtension libraries have been changed to AAR file.

Please download and confirm the newest SDK and Library from our Global Support Site.

2.1.1. Use Maven Repository

1. Insert following code in app/build.gradle.

dependencies {
    implementation 'com.starmicronics:stario:starioVersion'
    implementation 'com.starmicronics:starioextension:starioextensionVersion'
    implementation 'com.starmicronics:stariodevicesetting:stariodevicesettingversion'
    ...
}

Note

Please refer to app/build.gradle in each sample of examples folder for the latest library version.

2.1.2. Manually adding the link

  1. Select the libraries in the libs folder.

    Library
    • stario.aar

    • starioextension.aar

    • StarIODeviceSetting.aar

  2. Copy the library to the libs folder of project.

  3. Insert following code in app/build.gradle.

    dependencies {
        implementation(name: 'stario', ext: 'aar')
        implementation(name: 'starioextension', ext: 'aar')
        implementation(name: 'StarIODeviceSetting', ext: 'aar')
        ...
    }
    

    Note

    If using a starioextension.aar, stariodevicesetting.aar, insert also a stario.aar in the build.gradle.

(Option) When printing of QR code / PDF417 on TSP100 series, add about use of the library.

dependencies {
    implementation 'com.google.zxing:core:3.2.1'
    ...
}
  1. Insert following code in build.gradle.

    allprojects {
        repositories {
            flatDir {
                dirs 'libs'
            }
            ...
        }
        ...
    }
    

2.2. Project setting

2.2.1. Edit AndroidManifest.xml

  1. Double Click on the AndroidManifest.xml file.

  2. In case of TCP/IP connection, add about use of TCP/IP connection.In case of Bluetooth connection, add about use of Bluetooth connection.

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.BLUETOOTH" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
    

    Note

    When stario.aar is linked, the above items will be automatically added to the application’s AndroidManifest.xml.

    If you set targetSdkVersion to 31 or later, please refer to the following. Bluetooth permissions

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.BLUETOOTH"
        android:maxSdkVersion="30" />
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"
        android:maxSdkVersion="30" />
    
    <uses-permission android:name="android.permission.BLUETOOTH_SCAN"
        android:usesPermissionFlags="neverForLocation"
        tools:targetApi="31" />
    <uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
    
  3. In case of USB connection, add about use of USB connection.

    <intent-filter>
        <action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
        <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
    </intent-filter>
    
    <meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" android:resource="@xml/device_filter" />
    <meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" android:resource="@xml/accessory_filter" />
    

2.2.2. Edit device_filter.xml and accessory_filter.xml

  1. Double Click on the device_filter.xml (or accessory_filter.xml) file.

  2. In case of USB connection, add about use of USB connection.

    device_filter.xml
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <usb-device class="255" subclass="66" protocol="1" />
        <usb-device vendor-id="1305" product-id="0001" />   <!--IFBD-HU05/06, IFBD-HU07/08 - printerClass-->
        <usb-device vendor-id="1305" product-id="0002" />   <!--IFBD-HU05/06, IFBD-HU07/08 - vendorClass-->
        <usb-device vendor-id="1305" product-id="0003" />   <!--TSP100U/ECO/IIIU/IV  - printerClass-->
        <usb-device vendor-id="1305" product-id="0004" />   <!--TSP100U/ECO       - vendorClass-->
        <usb-device vendor-id="1305" product-id="0005" />   <!--TSP100GT/IIIU     - printerClass-->
        <usb-device vendor-id="1305" product-id="0006" />   <!--TSP100GT          - vendorClass-->
        <usb-device vendor-id="1305" product-id="0009" />   <!--FVP10             - printerClass-->
        <usb-device vendor-id="1305" product-id="0010" />   <!--FVP10             - vendorClass-->
        <usb-device vendor-id="1305" product-id="0011" />   <!--BSC10             - printerClass-->
        <usb-device vendor-id="1305" product-id="0012" />   <!--BSC10             - vendorClass-->
        <usb-device vendor-id="1305" product-id="0017" />   <!--BSC10BR           - printerClass-->
        <usb-device vendor-id="1305" product-id="0067" />   <!--SM-S210i/230i     - mobile printer-->
        <usb-device vendor-id="1305" product-id="0023" />   <!--mPOP              - printerClass-->
        <usb-device vendor-id="1305" product-id="0071" />   <!--mC-Print3         - printerClass-->
        <usb-device vendor-id="1305" product-id="0073" />   <!--mC-Print2         - printerClass-->
        <usb-device vendor-id="1305" product-id="0025" />   <!--mC-Label3         - printerClass-->
        <usb-device vendor-id="1305" product-id="0027" />   <!--BSC10II StarPRNT  - printerClass-->
        <usb-device vendor-id="1305" product-id="0075" />   <!--SK1-211/221/V211  - printerClass-->
        <usb-device vendor-id="1305" product-id="0077" />   <!--SK1-311/321/V311  - printerClass-->
    </resources>
    
    accessory_filter.xml
    <?xml version="1.0" encoding="utf-8"?>
    <resources>
        <usb-accessory model="Star TSP143IV-UE" manufacturer="STAR"/>
        <usb-accessory model="Star TSP143IV-UE SK" manufacturer="STAR"/>
        <usb-accessory model="Star TSP143IV-UEWB" manufacturer="STAR"/>
        <usb-accessory model="Star TSP143IV-UEWB SK" manufacturer="STAR"/>
        <usb-accessory model="mC-Label3" manufacturer="Star Micronics"/>
        <usb-accessory model="mC-Print3" manufacturer="Star Micronics"/>
        <usb-accessory model="mPOP" manufacturer="Star Micronics"/>
        <usb-accessory model="BSC10II" manufacturer="Star Micronics"/>
    </resources>
    

    About Star USB printers listed in device_filter.xml and accessory_filter.xml.If a user checks on the checkbox of connection permission dialog, then the dialog will not be displayed even if the cable is inserted or removed unless the application is reinstalled.In addition, the sample application will automatically launch when you insert the cable.

    TSP100IIIU can change product-id same as TSP100U/ECO or TSP100GT by memory switch setting.Memory switch setting can be done from Printer Configuration Software.Please refer to Utility/Driver.