Hello. I'm trying to create a modbus master application just to read values (function 1 to 4) actually I'm just trying to read coils just for testing and learning this package.

I created an Asynctask to make the connection with a single id 0 slave with 2 coils but I get fatal exception Caused by: java.lang.NoSuchMethodError: com.serotonin.messaging.MessageControl.setIoLog

I will post here the error and part of my code, so maybe I can get some guidance about this implementation.

I have set internet access for my app and also the asynctask to make the connection in the background. here's the error:

02-25 14:57:05.715  20957-21111/com.example.josempd.modbus4jtcpmaster E/AndroidRuntime? FATAL EXCEPTION: AsyncTask #4
    Process: com.example.josempd.modbus4jtcpmaster, PID: 20957
    java.lang.RuntimeException: An error occured while executing doInBackground()
            at android.os.AsyncTask$3.done(AsyncTask.java:300)
            at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
            at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
            at java.util.concurrent.FutureTask.run(FutureTask.java:242)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)
     Caused by: java.lang.NoSuchMethodError: com.serotonin.messaging.MessageControl.setIoLog
            at com.serotonin.modbus4j.ModbusMaster.getMessageControl(ModbusMaster.java:307)
            at com.serotonin.modbus4j.ip.tcp.TcpMaster.openConnection(TcpMaster.java:194)
            at com.serotonin.modbus4j.ip.tcp.TcpMaster.sendImpl(TcpMaster.java:93)
            at com.serotonin.modbus4j.ModbusMaster.send(ModbusMaster.java:92)
            at com.example.josempd.modbus4jtcpmaster.MainActivity$ConnectTask.doInBackground(MainActivity.java:130)
            at com.example.josempd.modbus4jtcpmaster.MainActivity$ConnectTask.doInBackground(MainActivity.java:85)
            at android.os.AsyncTask$2.call(AsyncTask.java:288)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)

and my current asynctask block:

@Override
        protected Void doInBackground(Void... arg0) {


            ModbusFactory factory = new ModbusFactory();
            IpParameters params = new IpParameters();
            params.setHost(IPMod);
            params.setPort(PortMod);
            params.setEncapsulated(false);
            ModbusMaster master = factory.createTcpMaster(params, false);
            master.setTimeout(500);
            master.setRetries(2);

            //Descripción de los parámetros
            Param = "Los parámetros son:" + "\n" +
                    "IP:" + IPMod + "\n" +
                    "Puerto:" + String.valueOf(PortMod) + "\n" +
                    "ID del esclavo:" + String.valueOf(slaveId) + "\n" +
                    "primera dirección:" + String.valueOf(RefMod) + "\n" +
                    "Número de direcciones:" + String.valueOf(CountMod);

            try {
                master.init();

                ReadCoilsRequest request = new ReadCoilsRequest(slaveId, RefMod, CountMod);

                ReadCoilsResponse response = (ReadCoilsResponse) master.send(request);

                Resp = response.getBooleanData().toString();

            } catch (ModbusInitException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                Resp = "Error: " + e.toString();
            }catch (ModbusTransportException e) {
                e.printStackTrace();
                Resp = "Error: " + e.toString();
            }
            finally {
                master.destroy();
            }
            return null;

        }

the imported libraries are the next:


dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:21.0.3'
    compile files('C:/Users/Josempd/AndroidStudioProjects/Modbus4JTCPMaster/libs/modbus4j-2.0.2.jar')
    compile files('C:/Users/Josempd/AndroidStudioProjects/Modbus4JTCPMaster/libs/serotonin-utils-2.1.7.jar')
    compile files('C:/Users/Josempd/AndroidStudioProjects/Modbus4JTCPMaster/libs/serotonin-timer-2.0.6.jar')
    compile files('C:/Users/Josempd/AndroidStudioProjects/Modbus4JTCPMaster/libs/maven-ant-tasks-2.1.3.jar')
    compile files('C:/Users/Josempd/AndroidStudioProjects/Modbus4JTCPMaster/libs/ant-contrib-1.0b3.jar')
}

I don't know if I'm missing libraries or any package or if I'm doing a bad implementation of the imported classes. Thanks in advance to everyone.